|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.struts.action.Action org.apache.struts.actions.DispatchAction org.appfuse.webapp.action.BaseAction
public class BaseAction
Implementation of Action that contains base methods for Actions as well as determines with methods to call in subclasses. This class uses the name of the button to determine which method to execute on the Action.
For example look at the following two buttons:
<html:submit property="method.findName"> <bean:message key="email.find"/> </html:submit> <html:submit property="method.findEmail"> <bean:message key="email.find"/> </html:submit>
The name of the button is set with the property parameter, i.e., the name of the first button is method.findName. The name of the second button is method.findEmail.
As per HTML/HTTP, whatever submit button that is pushed causes only that submit button's name to be sent as a request parameter to the action.
This action looks for the name by removing the prepender string "method.". The remaining part of the string is the name of the method to execute, e.g., pushing the first button will execute the findName method and the second button will execute the findEmail method.
This class extends DispatchAction and allows methods to be sent as regular GETs as well, i.e., <a href="emailAction.do?method=findEmail"/> would cause the findEmail method to be executed just as it would in a DispatchAction. Thus, you configure a ButtonNameDispatchAction exactly the way you configure a DispatchAction, i.e., set the mapping parameter to the name of the request parameter that holds the mehtod name.
Field Summary | |
---|---|
protected org.apache.commons.logging.Log |
log
|
Fields inherited from class org.apache.struts.actions.DispatchAction |
---|
clazz, messages, methods, types |
Fields inherited from class org.apache.struts.action.Action |
---|
defaultLocale, servlet |
Constructor Summary | |
---|---|
BaseAction()
|
Method Summary | |
---|---|
protected Object |
convert(Object o)
|
protected Object |
convertLists(Object o)
|
ActionForward |
execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
Override the execute method in DispatchAction to parse URLs and forward to methods without parameters. |
protected ActionForm |
getActionForm(ActionMapping mapping,
HttpServletRequest request)
Convenience method for getting an action form base on it's mapped scope. |
protected String |
getActionMethod(HttpServletRequest request,
String prepend)
Gets the method name based on the prepender passed to it. |
Object |
getBean(String name)
Convenience method to get Spring-initialized beans |
Map |
getConfiguration()
Convenience method to get the Configuration HashMap from the servlet context. |
ActionMessages |
getMessages(HttpServletRequest request)
Convenience method to initialize messages in a subclass. |
protected void |
removeFormBean(ActionMapping mapping,
HttpServletRequest request)
Convenience method for removing the obsolete form bean. |
protected void |
updateFormBean(ActionMapping mapping,
HttpServletRequest request,
ActionForm form)
Convenience method to update a formBean in it's scope |
Methods inherited from class org.apache.struts.actions.DispatchAction |
---|
cancelled, dispatchMethod, getMethod, getMethodName, getParameter, unspecified |
Methods inherited from class org.apache.struts.action.Action |
---|
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.apache.commons.logging.Log log
Constructor Detail |
---|
public BaseAction()
Method Detail |
---|
public Object getBean(String name)
name
-
protected Object convert(Object o) throws Exception
Exception
ConvertUtil.convert(java.lang.Object)
protected Object convertLists(Object o) throws Exception
Exception
ConvertUtil.convertLists(java.lang.Object)
public ActionMessages getMessages(HttpServletRequest request)
getMessages
in class Action
request
- the current request
protected String getActionMethod(HttpServletRequest request, String prepend)
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
This is based on the following system:
execute
in class DispatchAction
Exception
protected ActionForm getActionForm(ActionMapping mapping, HttpServletRequest request)
mapping
- The ActionMapping used to select this instancerequest
- The HTTP request we are processing
public Map getConfiguration()
protected void removeFormBean(ActionMapping mapping, HttpServletRequest request)
mapping
- The ActionMapping used to select this instancerequest
- The HTTP request we are processingprotected void updateFormBean(ActionMapping mapping, HttpServletRequest request, ActionForm form)
mapping
- The ActionMapping used to select this instancerequest
- The HTTP request we are processingform
- The ActionForm
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |