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

java.lang.Object
  extended byorg.springframework.context.support.ApplicationObjectSupport
      extended byorg.springframework.web.context.support.WebApplicationObjectSupport
          extended byorg.springframework.web.servlet.support.WebContentGenerator
              extended byorg.springframework.web.servlet.mvc.AbstractController
                  extended byorg.springframework.web.servlet.mvc.BaseCommandController
                      extended bycom.ervacon.springframework.web.servlet.mvc.webflow.BindAndValidateCommandAction
All Implemented Interfaces:
Action, org.springframework.context.ApplicationContextAware, org.springframework.web.servlet.mvc.Controller

public class BindAndValidateCommandAction
extends org.springframework.web.servlet.mvc.BaseCommandController
implements Action

Action implementation which creates an object (the command object) on execution and attempts to populate this object with request parameters. If there are binding or validation errors, an "error" event will be signaled. Otherwise "ok" is signaled.

The bind & validate functionality of this class is similar to that offered by the AbstractCommandController and BaseCommandController. Check the JavaDoc of those classes for exact details on the exposed configuration properties and hook methods. Check the SimpleFormAction if you are looking to implement a flow with SimpleFormController-like behaviour.

Exposed configuration properties

name default description
reuseCommand false Indicates whether or not an existing command object in the flow model should be reused. When set to false, a new command object will be created and stored in the flow model for each request.

Author:
Erwin Vervaet
See Also:
BaseCommandController, AbstractCommandController, SimpleFormAction, SimpleFormController

Field Summary
 
Fields inherited from class org.springframework.web.servlet.mvc.BaseCommandController
DEFAULT_COMMAND_NAME
 
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator
HEADER_CACHE_CONTROL, HEADER_EXPIRES, HEADER_PRAGMA, METHOD_GET, METHOD_POST
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Fields inherited from interface com.ervacon.springframework.web.servlet.mvc.webflow.Action
ERROR, OK
 
Constructor Summary
BindAndValidateCommandAction()
           
 
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.Object getCommand(javax.servlet.http.HttpServletRequest request, java.util.Map model)
          Retrieve a command object for the given request from given flow model.
protected  org.springframework.web.servlet.ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 boolean isReuseCommand()
          Indicates whether or not an existing command object in the flow model should be reused.
 void setReuseCommand(boolean reuseCommand)
          Set whether or not an existing command object in the flow model should be reused.
 
Methods inherited from class org.springframework.web.servlet.mvc.BaseCommandController
bindAndValidate, checkCommand, createBinder, createCommand, getCommand, getCommandClass, getCommandName, getMessageCodesResolver, getValidator, getValidators, initApplicationContext, initBinder, isValidateOnBinding, onBind, onBind, onBindAndValidate, setCommandClass, setCommandName, setMessageCodesResolver, setValidateOnBinding, setValidator, setValidators, suppressValidation
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractController
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession
 
Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, getCacheSeconds, getSupportedMethods, isRequireSession, isUseCacheControlHeader, isUseExpiresHeader, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseExpiresHeader
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, isContextRequired
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BindAndValidateCommandAction

public BindAndValidateCommandAction()
Method Detail

isReuseCommand

public boolean isReuseCommand()

Indicates whether or not an existing command object in the flow model should be reused. Defaults to false, so each call will result in a new command object being created.


setReuseCommand

public void setReuseCommand(boolean reuseCommand)

Set whether or not an existing command object in the flow model should be reused.


handleRequestInternal

protected org.springframework.web.servlet.ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request,
                                                                             javax.servlet.http.HttpServletResponse response)
                                                                      throws java.lang.Exception
Throws:
java.lang.Exception

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

getCommand

protected java.lang.Object getCommand(javax.servlet.http.HttpServletRequest request,
                                      java.util.Map model)
                               throws java.lang.Exception

Retrieve a command object for the given request from given flow model. If "reuseCommand" is set, an existing command object in the flow model will be reused. If not set or when the command is not present in the model, a new command will be created using the createCommand method.

Parameters:
request - current HTTP request
model - model of the flow
Returns:
object command to bind onto
Throws:
java.lang.Exception
See Also:
BaseCommandController.createCommand()