com.ervacon.springframework.web.servlet.mvc.webflow
Class MultiAction

java.lang.Object
  extended bycom.ervacon.springframework.web.servlet.mvc.webflow.MultiAction
All Implemented Interfaces:
Action
Direct Known Subclasses:
SimpleFormAction

public abstract class MultiAction
extends java.lang.Object
implements Action

Action implementation that bundles many action execution methods into a single action implementation class. Action execution methods defined by subclasses should follow the following signature:

 public String executeMethodName(HttpServletRequest request, HttpServletResponse response, Map model)
 
By default, the executeMethodName will be the name of the current state of the flow, so the follow state definition
 <action-state id="search">
 	<action name="searchAct" bean="myMultiAction"/>
 	<transition name="searchAct.ok" to="results"/>
 </action-state>
 
will execute the method
 public String search(HttpServletRequest request, HttpServletResponse response, Map model)
 
Note that action execution methods should not throw checked exceptions! They should signal an appropriate event or wrap the exception in a runtime exception.

A typical use of the MultiAction is to combine all CRUD operations for a certain domain object into a single controller. This action also allows you to reduce the number of action beans you have to configure in the application context

Exposed configuration properties:

name default description
delegate this The delegate object holding the execution methods.

Author:
Erwin Vervaet

Field Summary
 
Fields inherited from interface com.ervacon.springframework.web.servlet.mvc.webflow.Action
ERROR, OK
 
Constructor Summary
MultiAction()
           
 
Method Summary
 java.lang.String execute(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.Map model)
          Execute the action and return and signal an event that allows the containing flow to continue.
protected  java.lang.String getCurrentState(javax.servlet.http.HttpServletRequest request, java.util.Map model)
          Get the name of the current state of the flow executing this action.
protected  java.lang.Object getDelegate()
          Returns the delegate object holding the execution methods.
protected  java.lang.reflect.Method getExecuteMethod(java.lang.String executeMethodName)
          Get the action execution method with given name on the delegate object.
protected  java.lang.String getExecuteMethodName(java.lang.String currentState)
          Derive the name of an execution method from the name of the current state of the web flow.
protected  void setDelegate(java.lang.Object delegate)
          Set the delegate object holding the execution methods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiAction

public MultiAction()
Method Detail

getDelegate

protected java.lang.Object getDelegate()

Returns the delegate object holding the execution methods. Defaults to this object.


setDelegate

protected void setDelegate(java.lang.Object delegate)

Set the delegate object holding the execution methods.

Parameters:
delegate - The delegate to set.

getCurrentState

protected java.lang.String getCurrentState(javax.servlet.http.HttpServletRequest request,
                                           java.util.Map model)

Get the name of the current state of the flow executing this action.

The default implementation uses the WebFlowUtils.getWebFlowMementoStack(HttpServletRequest, Map) method, and thus assumes that the web flow id is available under its default id WebFlowController.FLOW_ID_MODEL_NAME in the model. If you have used WebFlowController.setFlowIdModelName(String) to change the name of the flow id in the model, redefine this method and call WebFlowUtils.getWebFlowMementoStack(HttpServletRequest, Map, String) with the correct name.

Parameters:
request - current HTTP request
model - model of the flow
Returns:
the name of the current state

getExecuteMethodName

protected java.lang.String getExecuteMethodName(java.lang.String currentState)

Derive the name of an execution method from the name of the current state of the web flow.

The default implementation just uses the name of the current state as execution method name.

Parameters:
currentState - the name of the current state of the flow
Returns:
the execution method name

getExecuteMethod

protected java.lang.reflect.Method getExecuteMethod(java.lang.String executeMethodName)
                                             throws java.lang.NoSuchMethodException,
                                                    java.lang.IllegalAccessException

Get the action execution method with given name on the delegate object. Execution methods should be of the form:

 public String executeMethodName(HttpServletRequest request, HttpServletResponse response, Map model)
 

Parameters:
executeMethodName - name of the execution method
Returns:
the execution method
Throws:
java.lang.NoSuchMethodException - when the method cannot be found on the delegate
java.lang.IllegalAccessException - when the method is not accessible on the delegate

execute

public java.lang.String execute(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response,
                                java.util.Map model)
Description copied from interface: Action

Execute the action and return and signal an event that allows the containing flow to continue. A null return value is not allowed: an action must return a valid event!

Note that actions cannot throw checked exceptions. They should signal an appropriate event or wrap the exception in a runtime exception.

Specified by:
execute in interface Action
Parameters:
request - current HTTP request
response - current HTTP response
model - model of the flow
Returns:
event that is signaled by the action, cannot be null