Beruflich Dokumente
Kultur Dokumente
LookupDispatchAction class is much like the DispatchAction class except that it uses
a Java Map and ApplicationResource.properties file to dispatch methods . At run time,
this class manages to delegate the request to one of the methods of the derived Action
class. Selection of a method depends on the value of the parameter passed from the
incoming request. LookupDispatchAction uses this parameter value to reverse-map to a
property in the Struts Resource bundle file (ie..ApplicationResource.properties). This
eliminates the need of creating an instance of ActionForm class.
package roseindia.net;
/**
* @author Amit Gupta
* @Web http://www.roseindia.net
* @Email struts@roseindia.net
**/
import java.io.*;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import org.apache.struts.actions.LookupDispatchAction;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
Application.properties
in the same directory structure where classes are saved.
roseindia.net.add=add
roseindia.net.edit=edit
roseindia.net.search=search
roseindia.net.save=save
<message-resources
parameter="roseindia.net.ApplicationResources"
/>
Here, Action mapping helps to select the method from the Action class for specific
requests. Note that the value specified with the parameter
attribute is used to delegate request to the required method of the
LookupDispatch_Action Class.
<action
path="/LookupDispatchAction"
type="roseindia.net.LookupDispatch_Action"
parameter="parameter"
input="/pages/LookupDispatchAction.jsp"
name="LookupDispatchActionForm"
scope="request"
validate="false">
<forward name="add"
path="/pages/LookupDispatchActionAdd.jsp" />
<forward name="edit"
path="/pages/LookupDispatchActionEdit.jsp" />
<forward name="search"
path="/pages/LookupDispatchActionSearch.jsp"/>
<forward name="save"
path="/pages/LookupDispatchActionSave.jsp" />
</action>
</html:html>
<li>
<html:link
page="/pages/LookupDispatchAction.jsp">Struts
File Upload</html:link>
<br>
Example demonstrates how
LookupDispatchAction class works.
</li>
To build and deploy the application go to Struts\Strutstutorial directory and type ant on
the command prompt. This will deploy the application. Open the browser and navigate to
the LookupDispatchAction.jsp page. Your browser displays the following
LookupDispatchAction page.
Selecting Call Add Section displays the following LookupDispatchActionAdd.jsp
page