Class LookupDispatchAction
- All Implemented Interfaces:
 Serializable
 An abstract Action that dispatches to the subclass
 mapped execute method. This is useful in cases where an HTML
 form has multiple submit buttons with the same name. The button name is
 specified by the parameter property of the corresponding
 ActionMapping. To configure the use of this action in your
 struts-config.xml file, create an entry like this:
   <action path="/test"
           type="org.example.MyAction"
           name="MyForm"
          scope="request"
          input="/test.jsp"
      parameter="method"/>
  which will use the value of the request parameter named "method" to locate the corresponding key in ApplicationResources. For example, you might have the following ApplicationResources.properties:
    button.add=Add Record
    button.delete=Delete Record
  And your JSP would have the following format for submit buttons:
   <html:form action="/test">
    <html:submit property="method">
      <bean:message key="button.add"/>
    </html:submit>
    <html:submit property="method">
      <bean:message key="button.delete"/>
    </html:submit>
  </html:form>
   Your subclass must implement both getKeyMethodMap and the methods defined in the map. An example of such implementations are:
  protected Map getKeyMethodMap() {
      Map map = new HashMap();
      map.put("button.add", "add");
      map.put("button.delete", "delete");
      return map;
  }
  public ActionForward add(ActionMapping mapping,
          ActionForm form,
          HttpServletRequest request,
          HttpServletResponse response)
          throws IOException, ServletException {
      // do add
      return mapping.findForward("success");
  }
  public ActionForward delete(ActionMapping mapping,
          ActionForm form,
          HttpServletRequest request,
          HttpServletResponse response)
          throws IOException, ServletException {
      // do delete
      return mapping.findForward("success");
  }
 
  Notes - If duplicate values exist for the keys
 returned by getKeys, only the first one found will be returned. If no
 corresponding key is found then an exception will be thrown. You can
 override the method unspecified to provide a custom handler.
 If the submit was cancelled (a html:cancel button was
 pressed), the custom handler cancelled will be used instead.
- See Also:
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionResource key to method name lookup.Reverse lookup map from resource value to resource key.Fields inherited from class org.apache.struts.extras.actions.DispatchAction
clazz, methods, typesFields inherited from class org.apache.struts.extras.actions.BaseAction
messages - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionexecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) Process the specified HTTP request, and create the corresponding HTTP response (or forward to another web component that will create it).Provides the mapping from resource key to method name.protected StringgetLookupMapName(HttpServletRequest request, String keyName, ActionMapping mapping) Lookup the method name corresponding to the client request's locale.protected StringgetMethodName(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String parameter) Returns the method name, given a parameter's value.Methods inherited from class org.apache.struts.extras.actions.DispatchAction
cancelled, dispatchMethod, getMethod, getParameter, unspecifiedMethods inherited from class org.apache.struts.action.Action
addErrors, addMessages, execute, generateToken, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet 
- 
Field Details
- 
localeMap
Reverse lookup map from resource value to resource key. - 
keyMethodMap
Resource key to method name lookup. 
 - 
 - 
Constructor Details
- 
LookupDispatchAction
public LookupDispatchAction() 
 - 
 - 
Method Details
- 
execute
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception Process the specified HTTP request, and create the corresponding HTTP response (or forward to another web component that will create it). Return anActionForwardinstance describing where and how control should be forwarded, ornullif the response has already been completed.- Overrides:
 executein classDispatchAction- Parameters:
 mapping- The ActionMapping used to select this instanceform- The optional ActionForm bean for this request (if any)request- The HTTP request we are processingresponse- The HTTP response we are creating- Returns:
 - Describes where and how control should be forwarded.
 - Throws:
 Exception- if an error occurs
 - 
getKeyMethodMap
Provides the mapping from resource key to method name.- Returns:
 - Resource key / method name map.
 
 - 
getLookupMapName
protected String getLookupMapName(HttpServletRequest request, String keyName, ActionMapping mapping) throws ServletException Lookup the method name corresponding to the client request's locale.- Parameters:
 request- The HTTP request we are processingkeyName- The parameter name to use as the properties keymapping- The ActionMapping used to select this instance- Returns:
 - The method's localized name.
 - Throws:
 ServletException- if keyName cannot be resolved- Since:
 - Struts 1.2.0
 
 - 
getMethodName
protected String getMethodName(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String parameter) throws Exception Returns the method name, given a parameter's value.- Overrides:
 getMethodNamein classDispatchAction- Parameters:
 mapping- The ActionMapping used to select this instanceform- The optional ActionForm bean for this request (if any)request- The HTTP request we are processingresponse- The HTTP response we are creatingparameter- TheActionMappingparameter's name- Returns:
 - The method's name.
 - Throws:
 Exception- if an error occurs- Since:
 - Struts 1.2.0
 
 
 -