Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.ibm.portal.struts.action
Class LookupDispatchAction

    java.lang.Object
      Action
          com.ibm.portal.struts.action.StrutsAction
              com.ibm.portal.struts.action.DispatchAction
                  com.ibm.portal.struts.action.LookupDispatchAction

    public abstract class LookupDispatchAction

extends DispatchAction

A portal friendly implementation of the LookupDispatchAction class. The following comments are from the Struts LookupDispatchAction javadoc

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="action"/>

which will use the value of the request parameter named "action" 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="action">
          <bean:message key="button.add"/>
        </html:submit>
        <html:submit property="action">
          <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,
              PortletRequest request )
              throws IOException, ServletException {
          // do add
          return mapping.findForward("success");
      }

      public ActionForward delete(ActionMapping mapping,
              ActionForm form,
              PortletRequest request )
              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.

Since:
  5.1

Field Summary
`protected java.util.Map` | `keyMethodMap` Resource key to method name lookup.
`protected java.util.Map` | `localeMap` Reverse lookup map from resource value to resource key.

Fields inherited from class com.ibm.portal.struts.action.DispatchAction
`clazz, log, messages, methods, types`

Constructor Summary
`LookupDispatchAction()` Constructor for this class

Method Summary
`ActionForward` | `execute(ActionMapping mapping, ActionForm form, ActionRequest request, ActionResponse response)` Execute the Struts action.
`protected abstract java.util.Map` | `getKeyMethodMap()` Provides the mapping from resource key to method name.

Methods inherited from class com.ibm.portal.struts.action.DispatchAction
`dispatchMethod, getMethod, unspecified`

Methods inherited from class com.ibm.portal.struts.action.StrutsAction
`sendError, sendError, sendError, sendError, sendError, sendError`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### localeMap

    protected java.util.Map localeMap

  Reverse lookup map from resource value to resource key.

### keyMethodMap

    protected java.util.Map keyMethodMap

  Resource key to method name lookup.

Constructor Detail

### LookupDispatchAction

    public LookupDispatchAction()

  Constructor for this class

Method Detail

### execute

    public ActionForward execute(ActionMapping mapping,
                                 ActionForm form,
                                 ActionRequest request,
                                 ActionResponse response)
                          throws java.lang.Exception

  Execute the Struts action.

  Overrides:
    `execute` in class `DispatchAction`
  Parameters:
    `mapping` - The ActionMapping used to select this instance
    `form` - The optional ActionForm bean for this request (if any)
    `request` - The Portlet request we are processing
    `response` - The Portlet response we are processing
  Returns:
    Describes where and how control should be forwarded, can be `null`
  Throws:
    `java.lang.Exception` - if the application business logic throws an exception

### getKeyMethodMap

    protected abstract java.util.Map getKeyMethodMap()

  Provides the mapping from resource key to method name.

  Returns:
    Resource key / method name map.

Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD