The major component in the Struts based application is the Action class. Action class only defines the next steps and logic processing for the application. The execute() method is called by the framework for the processing. All the business logic and all the flow is derived from the execute() method in the Action class. There is a special Action class which will permit the user to have more than one method which can be called by the framework and not just the execute() method. This class is DispatchAction. The class is helpful to have all the methods related to a single UI page in one Action class and developers need not to implement the logics in different classes. The method to be called on Action is decided with the parameter attribute in the <action> tag of struts-config.xml. The code for the mapping is given below.
<action path="/dispatchActionExample"
type="com.visualbuilder.DispatchActionExample"
parameter="method"
name="inputForm"
input="/index.jsp" />
Note:-The above mapping will check the method parameter and call the method with the name coming in the parameter. Add the following keys in the messageresources.properties file under WEB-INF/classes
error.unspecified= Unspecified Called.
error.add= Add Called.
error.delete= delete Called.
error.view= View Called.
Example For DispatchAction
(1) Struts-config.xml file
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<!-- ================================================ Form Bean Definitions -->
<form-beans>
<form-bean name="inputForm" type="com.visualbuilder.InputForm" />
</form-beans>
<!-- ========================================= Global Exception Definitions -->
<global-exceptions></global-exceptions>
<!-- =========================================== Global Forward Definitions -->
<global-forwards></global-forwards>
<!-- =========================================== Action Mapping Definitions -->
<action-mappings>
<action path="/dispatchActionExample"
type="com.visualbuilder.DispatchActionExample"
parameter="method"
name="inputForm"
input="/index.jsp" />
</action-mappings>
<!-- ======================================== Message Resources Definitions -->
<message-resources parameter="MessageResources" />
</struts-config>
Jsp Discussion
- - Two forms in one JSP
- - PASS VARIABLES BETWEEN 2
- - Table data
- - Unable to laod the image
- - The Ultimate Web UI Frame





