| org.apache.struts.actions.BaseAction org.apache.struts.actions.DispatchAction org.apache.struts.actions.MappingDispatchAction
All known Subclasses: org.apache.struts.webapp.dispatch.MappingDispatchExampleAction, org.apache.struts.apps.mailreader.actions.BaseAction,
MappingDispatchAction | public class MappingDispatchAction extends DispatchAction (Code) | | An abstract Action that dispatches to a public method
that is named by the parameter attribute of the corresponding
ActionMapping. This is useful for developers who prefer to combine many
related actions into a single Action class.
To configure the use of this action in your struts-config.xml
file, create an entry like this:
<action path="/saveSubscription"
type="org.example.SubscriptionAction"
name="subscriptionForm"
scope="request"
input="/subscription.jsp"
parameter="method"/>
where 'method' is the name of a method in your subclass of
MappingDispatchAction that has the same signature (other than method name)
of the standard Action.execute method. For example, you might combine the
methods for managing a subscription into a single MappingDispatchAction
class using the following methods:
- public ActionForward create(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
Exception
- public ActionForward edit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
Exception
- public ActionForward save(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
Exception
- public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
Exception
- public ActionForward list(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
Exception
for which you would create corresponding <action> configurations
that reference this class:
<action path="/createSubscription"
type="org.example.SubscriptionAction"
parameter="create">
<forward name="success" path="/editSubscription.jsp"/>
</action>
<action path="/editSubscription"
type="org.example.SubscriptionAction"
parameter="edit">
<forward name="success" path="/editSubscription.jsp"/>
</action>
<action path="/saveSubscription"
type="org.example.SubscriptionAction"
parameter="save"
name="subscriptionForm"
validate="true"
input="/editSubscription.jsp"
scope="request">
<forward name="success" path="/savedSubscription.jsp"/>
</action>
<action path="/deleteSubscription"
type="org.example.SubscriptionAction"
name="subscriptionForm"
scope="request"
input="/subscription.jsp"
parameter="delete">
<forward name="success" path="/deletedSubscription.jsp"/>
</action>
<action path="/listSubscriptions"
type="org.example.SubscriptionAction"
parameter="list">
<forward name="success" path="/subscriptionList.jsp"/>
</action>
NOTE - Unlike DispatchAction, mapping characteristics
may differ between the various handlers, so you can combine actions in the
same class that, for example, differ in their use of forms or validation.
Also, a request parameter, which would be visible to the application user,
is not required to enable selection of the handler method.
version: $Rev: 480570 $ $Date: 2006-11-29 07:39:37 -0600 (Wed, 29 Nov 2006) $ since: Struts 1.2 |
Method Summary | |
public ActionForward | execute(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). | protected String | getMethodName(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String parameter) Returns the method name, given a parameter's value. | protected String | getParameter(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) | protected ActionForward | unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) Method which is dispatched to when there is no value for the parameter
in the ActionMapping. |
execute | public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception(Code) | | Process the specified HTTP request, and create the corresponding HTTP
response (or forward to another web component that will create it).
Return an ActionForward instance describing where and how
control should be forwarded, or null if the response has
already been completed.
This method dispatches the request to other methods of
MappingDispatchAction using the 'parameter' attribute of
ActionMapping and Java Introspection.
Parameters: mapping - The ActionMapping used to select this instance Parameters: form - The optional ActionForm bean for this request (if any) Parameters: request - The HTTP request we are processing Parameters: response - The HTTP response we are creating Return an ActionForward instance describing whereand how control should be forwarded, or null ifthe response has already been completed. throws: Exception - if an exception occurs |
getMethodName | protected String getMethodName(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String parameter) throws Exception(Code) | | Returns the method name, given a parameter's value.
Parameters: mapping - The ActionMapping used to select this instance Parameters: form - The optional ActionForm bean for this request (ifany) Parameters: request - The HTTP request we are processing Parameters: response - The HTTP response we are creating Parameters: parameter - The ActionMapping parameter's name The method's name. throws: Exception - if an error occurs since: Struts 1.2.0 |
getParameter | protected String getParameter(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception(Code) | | Returns the parameter value.
Parameters: mapping - The ActionMapping used to select this instance Parameters: form - The optional ActionForm bean for this request (if any) Parameters: request - The HTTP request we are processing Parameters: response - The HTTP response we are creating The ActionMapping parameter's value |
unspecified | protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception(Code) | | Method which is dispatched to when there is no value for the parameter
in the ActionMapping. Subclasses of MappingDispatchAction
should override this method if they wish to provide default behavior
different than throwing a ServletException.
Parameters: mapping - The ActionMapping used to select this instance Parameters: form - The optional ActionForm bean for this request (if any) Parameters: request - The HTTP request we are processing Parameters: response - The HTTP response we are creating Return an ActionForward instance describing whereand how control should be forwarded, or null ifthe response has already been completed. throws: Exception - if an exception occurs |
Methods inherited from org.apache.struts.actions.DispatchAction | protected ActionForward cancelled(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc) protected ActionForward dispatchMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String name) throws Exception(Code)(Java Doc) public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc) protected Method getMethod(String name) throws NoSuchMethodException(Code)(Java Doc) protected String getMethodName(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String parameter) throws Exception(Code)(Java Doc) protected String getParameter(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc) protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc)
|
|
|