@Deprecated public class CancellableFormController extends SimpleFormController
Extension of SimpleFormController
that supports "cancellation"
of form processing. By default, this controller looks for a given parameter in the
request, identified by the cancelParamKey
. If this parameter is present,
then the controller will return the configured cancelView
, otherwise
processing is passed back to the superclass.
Workflow
(in addition to the superclass):
processFormSubmission
which calls
isCancelRequest(HttpServletRequest)
to see if the incoming request is to cancel the
current form entry. By default, isCancelRequest(HttpServletRequest)
returns true
if the configured cancelParamKey
exists in the request.
This behavior can be overridden in subclasses.isCancelRequest(HttpServletRequest)
returns false
, then the controller
will delegate all processing back to SimpleFormController
,
otherwise it will call the onCancel(HttpServletRequest, HttpServletResponse, java.lang.Object)
version with all parameters.
By default, that method will delegate to the onCancel(HttpServletRequest, HttpServletResponse, java.lang.Object)
version with just
the command object, which will in turn simply return the configured
cancelView
. This behavior can be overridden in subclasses.Thanks to Erwin Bolwidt for submitting the original prototype of such a cancellable form controller!
setCancelParamKey(java.lang.String)
,
setCancelView(java.lang.String)
,
#isCancelRequest(javax.servlet.http.HttpServletRequest)
,
#onCancel(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, Object)
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
cancelParamKey
Deprecated.
|
private java.lang.String |
cancelView
Deprecated.
|
private static java.lang.String |
PARAM_CANCEL
Deprecated.
Default parameter triggering the cancel action.
|
DEFAULT_COMMAND_NAME
METHOD_GET, METHOD_HEAD, METHOD_POST
logger
Constructor and Description |
---|
CancellableFormController()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCancelParamKey()
Deprecated.
Return the key of the request parameter used to identify a cancel request.
|
java.lang.String |
getCancelView()
Deprecated.
Gets the name of the cancel view.
|
protected boolean |
isCancelRequest(HttpServletRequest request)
Deprecated.
Determine whether the incoming request is a request to cancel the
processing of the current form.
|
protected boolean |
isFormSubmission(HttpServletRequest request)
Deprecated.
Consider an explicit cancel request as a form submission too.
|
protected ModelAndView |
onCancel(HttpServletRequest request,
HttpServletResponse response,
java.lang.Object command)
Deprecated.
Callback method for handling a cancel request.
|
protected ModelAndView |
onCancel(java.lang.Object command)
Deprecated.
Simple
onCancel version. |
protected ModelAndView |
processFormSubmission(HttpServletRequest request,
HttpServletResponse response,
java.lang.Object command,
BindException errors)
Deprecated.
This implementation first checks to see if the incoming is a cancel request,
through a call to
isCancelRequest(HttpServletRequest) . |
void |
setCancelParamKey(java.lang.String cancelParamKey)
Deprecated.
Set the key of the request parameter used to identify a cancel request.
|
void |
setCancelView(java.lang.String cancelView)
Deprecated.
Sets the name of the cancel view.
|
protected boolean |
suppressValidation(HttpServletRequest request,
java.lang.Object command)
Deprecated.
Suppress validation for an explicit cancel request too.
|
doSubmitAction, getFormView, getSuccessView, isFormChangeRequest, isFormChangeRequest, onFormChange, onFormChange, onSubmit, onSubmit, onSubmit, referenceData, referenceData, setFormView, setSuccessView, showForm, showForm
currentFormObject, formBackingObject, getCommand, getErrorsForNewForm, getFormSessionAttributeName, getFormSessionAttributeName, handleInvalidSubmit, handleRequestInternal, isBindOnNewForm, isSessionForm, onBindOnNewForm, onBindOnNewForm, setBindOnNewForm, setSessionForm, showForm, showForm, showNewForm
bindAndValidate, checkCommand, createBinder, createCommand, getBindingErrorProcessor, getCommandClass, getCommandName, getMessageCodesResolver, getPropertyEditorRegistrars, getValidator, getValidators, getWebBindingInitializer, initApplicationContext, initBinder, isValidateOnBinding, onBind, onBind, onBindAndValidate, prepareBinder, setBindingErrorProcessor, setCommandClass, setCommandName, setMessageCodesResolver, setPropertyEditorRegistrar, setPropertyEditorRegistrars, setValidateOnBinding, setValidator, setValidators, setWebBindingInitializer, suppressBinding, suppressValidation, suppressValidation, useDirectFieldAccess
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, getCacheSeconds, getSupportedMethods, isAlwaysMustRevalidate, isRequireSession, isUseCacheControlHeader, isUseCacheControlNoStore, isUseExpiresHeader, preventCaching, setAlwaysMustRevalidate, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseCacheControlNoStore, setUseExpiresHeader
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
private static final java.lang.String PARAM_CANCEL
private java.lang.String cancelParamKey
private java.lang.String cancelView
public final void setCancelParamKey(java.lang.String cancelParamKey)
The parameter is recognized both when sent as a plain parameter ("_cancel") or when triggered by an image button ("_cancel.x").
public final java.lang.String getCancelParamKey()
public final void setCancelView(java.lang.String cancelView)
public final java.lang.String getCancelView()
protected boolean isFormSubmission(HttpServletRequest request)
isFormSubmission
in class AbstractFormController
request
- current HTTP request#isCancelRequest(javax.servlet.http.HttpServletRequest)
protected boolean suppressValidation(HttpServletRequest request, java.lang.Object command)
suppressValidation
in class SimpleFormController
request
- current HTTP requestcommand
- the command object to validate#isCancelRequest(javax.servlet.http.HttpServletRequest)
protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, java.lang.Object command, BindException errors) throws java.lang.Exception
isCancelRequest(HttpServletRequest)
. If so, control is passed to
onCancel(HttpServletRequest, HttpServletResponse, java.lang.Object)
; otherwise, control is passed up to
SimpleFormController.processFormSubmission(HttpServletRequest, HttpServletResponse, java.lang.Object, org.springframework.validation.BindException)
.processFormSubmission
in class SimpleFormController
request
- current servlet requestresponse
- current servlet responsecommand
- form object with request parameters bound onto iterrors
- holder without errors (subclass can add errors if it wants to)null
java.lang.Exception
- in case of errorsisCancelRequest(HttpServletRequest)
,
#onCancel(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, Object)
,
SimpleFormController.processFormSubmission(HttpServletRequest, HttpServletResponse, java.lang.Object, org.springframework.validation.BindException)
protected boolean isCancelRequest(HttpServletRequest request)
By default, this method returns true
if a parameter
matching the configured cancelParamKey
is present in
the request, otherwise it returns false
. Subclasses may
override this method to provide custom logic to detect a cancel request.
The parameter is recognized both when sent as a plain parameter ("_cancel") or when triggered by an image button ("_cancel.x").
request
- current HTTP requestsetCancelParamKey(java.lang.String)
,
PARAM_CANCEL
protected ModelAndView onCancel(HttpServletRequest request, HttpServletResponse response, java.lang.Object command) throws java.lang.Exception
isCancelRequest(HttpServletRequest)
returns true
.
Default implementation delegates to onCancel(Object)
to return
the configured cancelView
. Subclasses may override either of the two
methods to build a custom ModelAndView
that may contain model
parameters used in the cancel view.
If you simply want to move the user to a new view and you don't want to add
additional model parameters, use setCancelView(String)
rather than
overriding an onCancel
method.
request
- current servlet requestresponse
- current servlet responsecommand
- form object with request parameters bound onto itnull
java.lang.Exception
- in case of errors#isCancelRequest(javax.servlet.http.HttpServletRequest)
,
onCancel(Object)
,
setCancelView(java.lang.String)
protected ModelAndView onCancel(java.lang.Object command) throws java.lang.Exception
onCancel
version. Called by the default implementation
of the onCancel
version with all parameters.
Default implementation returns eturns the configured cancelView
.
Subclasses may override this method to build a custom ModelAndView
that may contain model parameters used in the cancel view.
If you simply want to move the user to a new view and you don't want to add
additional model parameters, use setCancelView(String)
rather than
overriding an onCancel
method.
command
- form object with request parameters bound onto itnull
java.lang.Exception
- in case of errors#onCancel(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, Object)
,
setCancelView(java.lang.String)