Struts Cross Reference
Struts Cross Reference
STRUTS
CROSS
REFERENCE
Prepared by
Roger W. Barnes
Of
Project Refinery, Inc.
TABLE OF CONTENTS
OVERVIEW.................................................................................................................................. 3
STRUTS -[Link] ............................................................................................................. 4
[Link]..................................................................................................................................... 5
[Link]..................................................................................................... 6
[Link]................................................................................................. 9
[Link]............................................................................................................................. 10
[Link]........................................................................................................................ 11
[Link].............................................................................................. 12
[Link] .......................................................................................... 13
[Link] FILE .............................................................................. 14
TYPICAL STRUTS SYSTEM FLOW ..................................................................................... 15
Overview
The purpose of this document is to provide a cross reference of an example application using the
Struts framework. This document displays where information from the [Link] file
relate to Java Server Pages using the Struts tag libraries, and to Java classes extending both the
ActionForm and Action classes.
[Link]
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"[Link]
<struts-config>
<form-bean name="StrutsInputFormBean"
type="[Link]" />
<form-bean name="StrutsDisplayFormBean"
type="[Link]" />
</form-beans>
<action path="/StrutsInputPath"
type="[Link]"
name="StrutsInputFormBean"
scope="request"
input="/[Link]">
<action path="/StrutsDisplayPath"
type="[Link]"
name="StrutsDisplayFormBean"
scope="request"
input="/[Link]" >
</action>
</action-mappings>
</struts-config>
[Link]
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"[Link]
<web-app id="WebApp">
<display-name>StrutsExampleWeb</display-name>
<!-- Action Servlet Configuration -->
<servlet id="Servlet_1">
<servlet-name>action</servlet-name>
<servlet-class>[Link]</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>strutsexample </param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>WEB-INF/[Link] </param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* The purpose of this class is to handle the input fields entered on a JSP.
* @author Roger W Barnes
* @version $Revision: 1.0 $ $Date: 2001/11/02 [Link] $
*/
public final class StrutsInputForm extends ActionForm {
/**
* The name.
*/
private String name = "";
/**
* The address.
*/
private String address = "";
/**
* The city.
*/
private String city = "";
/**
* The state.
*/
private String state = "";
/**
* The zipcode.
*/
private String zipcode = "";
/**
* The action.
*/
private String action = "";
/**
* Gets the name
* @return Returns a String
*/
public String getName() {
return name;
}
/**
* Sets the name
* @param name The name to set
*/
public void setName(String name) {
[Link] = name;
}
/**
* Gets the address
* @return Returns a String
*/
public String getAddress() {
return address;
}
/**
* Sets the address
* @param address The address to set
*/
public void setAddress(String address) {
[Link] = address;
}
/**
* Gets the city
* @return Returns a String
*/
public String getCity() {
return city;
}
/**
* Sets the city
* @param city The city to set
*/
public void setCity(String city) {
[Link] = city;
}
/**
* Gets the state
* @return Returns a String
*/
public String getState() {
return state;
}
/**
* Sets the state
* @param state The state to set
*/
public void setState(String state) {
[Link] = state;
}
/**
* Gets the zipcode
* @return Returns a String
*/
public String getZipcode() {
return zipcode;
}
/**
* Sets the zipcode
* @param zipcode The zipcode to set
*/
public void setZipcode(String zipcode) {
[Link] = zipcode;
}
/**
* Gets the action
* @return Returns a String
*/
public String getAction() {
return action;
}
/**
* Sets the action
* @param action The action to set
*/
public void setAction(String action) {
[Link] = action;
}
/**
* Reset all properties to their default values.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
action = null;
}
/**
* Validate the properties of this form bean, and return an array of
* message keys for any errors we encounter.
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
/** Perform validation tests on the name field */
if ((name == null) || ([Link]() < 1))
[Link]("name", new ActionError("[Link]", name));
/** Perform validation tests on the address field */
if ((address == null) || ([Link]() < 1))
[Link]("address", new ActionError("[Link]", address));
/** Perform validation tests on the city field */
if ((city == null) || ([Link]() < 1))
[Link]("city", new ActionError("[Link]", city));
/** Perform validation tests on the state field */
if ((state == null) || ([Link]() < 1))
[Link]("state", new ActionError("[Link]", state));
/** Perform validation tests on the zipcode field */
if ((zipcode == null) || ([Link]() < 1))
[Link]("zipcode", new ActionError("[Link]", zipcode));
/** Perform validation tests on the action field */
if ((action == null) || ([Link]() < 1))
[Link]("action", new ActionError("[Link]", action));
return errors;
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* Implementation of <strong>Action</strong> that handles the Index Account Action.
*
* @author Roger W Barnes
* @version $Revision: 1.0 $ $Date: 2002/03/11 [Link] $
*/
}
}
[Link]
</html:form>
</body>
</html:html>
[Link] p
<html:html>
<head>
<title><bean:message key="strutsexample.title2"/></title>
<META name="GENERATOR" content="IBM WebSphere Studio">
</head>
<body>
</html:form>
</body>
</html:html>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* The purpose of this class is to handle the input fields entered on a JSP form page.
* @author Roger W Barnes
* @version $Revision: 1.0 $ $Date: 2001/11/02 [Link] $
*/
public final class StrutsDisplayForm extends ActionForm {
/**
* The action.
*/
private String action = "";
/**
* Gets the action
* @return Returns a String
*/
public String getAction() {
return action;
}
/**
* Sets the action
* @param action The action to set
*/
public void setAction(String action) {
[Link] = action;
}
/**
* Reset all properties to their default values.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
action = null;
}
/**
* Validate the properties of this form bean, and return an array of
* message keys for any errors we encounter.
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
/** Perform validation tests on the action field */
if ((action == null) || ([Link]() < 1))
[Link]("action", new ActionError("[Link]", action));
return errors;
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* Implementation of <strong>Action</strong> that handles the Index Account Action.
*
* @author Roger W Barnes
* @version $Revision: 1.0 $ $Date: 2002/03/11 [Link] $
*/
}
}
[Link] File