Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.struts.action.Action
org.apache.struts.actions.DispatchAction
org.apache.struts.actions.EventDispatchAction
public class EventDispatchAction
extends DispatchAction
parameter
attribute of the corresponding
ActionMapping and matches a submission parameter. This is useful for
developers who prefer to use many submit buttons, images, or submit links
on a single form and whose related actions exist in a single Action class.
The method(s) must have the same signature (other than method name) of the
standard Action.execute method.
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="save,back,recalc=recalculate,default=save"/>
where parameter
contains three possible methods and one
default method if nothing matches (such as the user pressing the enter key).
For utility purposes, you can use the key=value
notation to
alias methods so that they are exposed as different form element names, in the
event of a naming conflict or otherwise. In this example, the recalc
button (via a request parameter) will invoke the recalculate
method. The security-minded person may find this feature valuable to
obfuscate and not expose the methods.
The default key is purely optional. If this is not specified
and no parameters match the list of method keys, null
is
returned which means the unspecified
method will be invoked.
The order of the parameters are guaranteed to be iterated in the order
specified. If multiple buttons were accidently submitted, the first match in
the list will be dispatched.
Field Summary | |
private static String |
|
private static Log |
|
Fields inherited from class org.apache.struts.actions.DispatchAction | |
clazz , log , messages , methods , types |
Fields inherited from class org.apache.struts.action.Action | |
defaultLocale , servlet , token |
Method Summary | |
protected String |
|
protected ActionForward |
|
Methods inherited from class org.apache.struts.actions.DispatchAction | |
cancelled , dispatchMethod , execute , getMethod , getMethodName , getParameter , unspecified |
Methods inherited from class org.apache.struts.action.Action | |
addErrors , addMessages , execute , execute , generateToken , getDataSource , getDataSource , getErrors , getLocale , getMessages , getResources , getResources , getServlet , isCancelled , isTokenValid , isTokenValid , resetToken , saveErrors , saveErrors , saveErrors , saveMessages , saveMessages , saveToken , setLocale , setServlet |
private static final String DEFAULT_METHOD_KEY
The method key, if present, to use if other specified method keys do not match a request parameter.
private static final Log LOG
Commons Logging instance.
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:
- getMethodName in interface DispatchAction
- 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
- TheActionMapping
parameter's name
- Returns:
- The method's name.
protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
Method which is dispatched to when there is no value for specified request parameter included in the request. Subclasses ofDispatchAction
should override this method if they wish to provide default behavior different than throwing a ServletException.
- Overrides:
- unspecified in interface DispatchAction
- Parameters:
mapping
- The ActionMapping used to select this instanceform
- The optional ActionForm bean for this request (if any)request
- The non-HTTP request we are processingresponse
- The non-HTTP response we are creating
- Returns:
- The forward to which control should be transferred, or
null
if the response has been completed.