java.lang.Objectorg.apache.struts.action.Action
org.apache.struts.actions.DispatchAction
Direct Known Subclasses:
LookupDispatchAction, EventDispatchAction, MappingDispatchAction
An abstract Action that dispatches to a public
method that is named by the request parameter whose name is specified
by the parameter
property of the corresponding
ActionMapping. This Action is useful for developers who prefer to
combine many similar actions into a single Action class, in order to
simplify their application design.
To configure the use of this action in your
struts-config.xml
file, create an entry like this:
<action path="/saveSubscription"
type="org.apache.struts.actions.DispatchAction"
name="subscriptionForm"
scope="request"
input="/subscription.jsp"
parameter="method"/>
which will use the value of the request parameter named "method" to pick the appropriate "execute" method, which must have the same signature (other than method name) of the standard Action.execute method. For example, you might have the following three methods in the same action:
and call one of the methods with a URL like this:
http://localhost:8080/myapp/saveSubscription.do?method=update
NOTE - All of the other mapping characteristics of
this action must be shared by the various handlers. This places some
constraints over what types of handlers may reasonably be packaged into
the same DispatchAction
subclass.
NOTE - If the value of the request parameter is empty,
a method named unspecified
is called. The default action is
to throw an exception. If the request was cancelled (a html:cancel
button was pressed), the custom handler cancelled
will be used instead.
You can also override the getMethodName
method to override the action's
default handler selection.
$
- Rev: 384089 $ $Date: 2006-03-08 01:50:52 +0000 (Wed, 08 Mar 2006) $Field Summary | ||
---|---|---|
protected Class | clazz | The Class instance of this DispatchAction class. |
protected static Log | log | Commons Logging instance. |
protected static MessageResources | messages | The message resources for this package. |
protected HashMap | methods | The set of Method objects we have introspected for this class, keyed by method name. This collection is populated as different methods are called, so that introspection needs to occur only once per method name. |
protected Class[] | types | The set of argument type classes for the reflected method call. These are the same for all calls, so calculate them only once. |
Method from org.apache.struts.actions.DispatchAction Summary: |
---|
cancelled, dispatchMethod, execute, getMethod, getMethodName, getParameter, unspecified |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from org.apache.struts.actions.DispatchAction Detail: |
---|
DispatchAction should override this method if
they wish to provide default behavior different than returning null. |
|
ActionForward instance describing where and how
control should be forwarded, or null if the response has
already been completed. |
execute
method does. |
|
Returns the parameter value. |
DispatchAction should override this method if they wish
to provide default behavior different than throwing a ServletException. |