|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.context.support.ApplicationObjectSupport org.springframework.web.context.support.WebApplicationObjectSupport org.springframework.web.servlet.support.WebContentGenerator org.springframework.web.servlet.mvc.AbstractController org.springframework.web.servlet.mvc.BaseCommandController org.springframework.web.servlet.mvc.AbstractFormController org.springframework.web.servlet.mvc.SimpleFormController uk.co.lakesidetech.springframework.web.servlet.mvc.multiaction.SimpleMultiActionFormController
The SimpleMultiActionFormController
provides a multiple form processing action
similar to MultiActionController
for form processing allowing a concrete class to
benefit from the binding and error handling capabilties of the FormController but execute different
submission actions.
As the SimpleFormController will execute binding and validation actions before processing the selected submit action, this may result in the action not executing if there are errors on the form even if this is not the final submit action.
When combined with the SubmitParameterPropertiesMethodNameResolver
this form can handle different
actions for different submit buttons much like the _finish and _cancel of the AbstractWizardFormController
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 |
Constructor Summary | |
SimpleMultiActionFormController()
|
Method Summary | |
protected void |
defaultBindAndValidate(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
org.springframework.validation.BindException errors)
Subclasses can override this to provide cross action/method validation. |
org.springframework.web.servlet.mvc.multiaction.MethodNameResolver |
getMethodNameResolver()
Get the method name resolver object |
protected void |
onBindAndValidate(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
org.springframework.validation.BindException errors)
This method looks for validators/binders for the action by appending the word Validator onto the method name. |
protected org.springframework.web.servlet.ModelAndView |
processFormSubmission(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object command,
org.springframework.validation.BindException errors)
Process the form submission, if the form is errored then reshow the form otherwise resolve the method to call in the concrete class using the set MethodNameResolver |
void |
setMethodNameResolver(org.springframework.web.servlet.mvc.multiaction.MethodNameResolver methodNameResolver)
Set the method name resolver objerct |
Methods inherited from class org.springframework.web.servlet.mvc.SimpleFormController |
doSubmitAction, getFormView, getSuccessView, isFormChangeRequest, onSubmit, onSubmit, onSubmit, referenceData, referenceData, setFormView, setSuccessView, showForm, suppressValidation |
Methods inherited from class org.springframework.web.servlet.mvc.AbstractFormController |
formBackingObject, getCommand, getErrorsForNewForm, getFormSessionAttributeName, handleInvalidSubmit, handleRequestInternal, isBindOnNewForm, isFormSubmission, isSessionForm, setBindOnNewForm, setSessionForm, showForm, showForm, showNewForm |
Methods inherited from class org.springframework.web.servlet.mvc.BaseCommandController |
bindAndValidate, checkCommand, createBinder, createCommand, getCommandClass, getCommandName, getMessageCodesResolver, getValidator, getValidators, initApplicationContext, initBinder, isValidateOnBinding, onBind, onBind, setCommandClass, setCommandName, setMessageCodesResolver, setValidateOnBinding, setValidator, setValidators |
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 |
public SimpleMultiActionFormController()
Method Detail |
public final void setMethodNameResolver(org.springframework.web.servlet.mvc.multiaction.MethodNameResolver methodNameResolver)
methodNameResolver
- public final org.springframework.web.servlet.mvc.multiaction.MethodNameResolver getMethodNameResolver()
protected final void onBindAndValidate(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.BindException errors) throws java.lang.Exception
This method looks for validators/binders for the action by appending the word Validator onto the method name.
e.g. If the properties file defined a method foo for submit button this routine will look for the method:
public void fooValidator(HttpServletRequest request, Object command, BindException errors);
java.lang.Exception
protected void defaultBindAndValidate(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.BindException errors)
request
- command
- errors
- protected org.springframework.web.servlet.ModelAndView processFormSubmission(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object command, org.springframework.validation.BindException errors) throws java.lang.Exception
Process the form submission, if the form is errored then reshow the form otherwise resolve the method to call in the concrete class using the set MethodNameResolver
Subclasses must implement the methods setup to respond the the various submit buttons.Consider the following config file: <bean id="submitActionParamResolver" class="uk.co.lakesidetech.springframework.web.servlet.mvc.multiaction.SubmitParameterPropertiesMethodNameResolver"> <property name="mappings”> <props> <prop key="_addOrganisation">addOrganisationSubmit</prop> <prop key="_addCapability">addCapabilitySubmit</prop> <prop key="_cancel">cancelSubmit</prop> <prop key="_finish">finalSubmit</prop> </props> </property> <property name="defaultMethodName"> <value>finalSubmit</value> </property>
The subclass would need to contain the methods: public void addOrganisationSubmit(HttpServletRequest request,Object command, BindException errors) public void addCapabilitySubmit(HttpServletRequest request,Object command, BindException errors) public void finalSubmit(HttpServletRequest request,Object command, BindException errors)
If the form submission object returns a ModelAndView object then this is considered the user response and that ModelAndView is rendered otherwise the showForm is rendered to show the returned form.
request
- the request objectresponse
- the response objectcommand
- the command objecterrors
- bind errors object
java.lang.Exception
AbstractFormController.processFormSubmission(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |