| org.springframework.web.servlet.mvc.AbstractController org.springframework.web.servlet.mvc.BaseCommandController org.springframework.web.servlet.mvc.AbstractFormController org.springframework.web.servlet.mvc.AbstractWizardFormController
AbstractWizardFormController | abstract public class AbstractWizardFormController extends AbstractFormController (Code) | | Form controller for typical wizard-style workflows.
In contrast to classic forms, wizards have more than one form view page.
Therefore, there are various actions instead of one single submit action:
- finish: trying to leave the wizard successfully, that is, perform its
final action, and thus requiring a valid state;
- cancel: leaving the wizard without performing its final action, and
thus without regard to the validity of its current state;
- page change: showing another wizard page, e.g. the next or previous
one, with regard to "dirty back" and "dirty forward".
Finish and cancel actions can be triggered by request parameters, named
PARAM_FINISH ("_finish") and PARAM_CANCEL ("_cancel"), ignoring parameter
values to allow for HTML buttons. The target page for page changes can be
specified by PARAM_TARGET, appending the page number to the parameter name
(e.g. "_target1"). The action parameters are recognized when triggered by
image buttons too (via "_finish.x", "_abort.x", or "_target1.x").
The current page number will be stored in the session. It can also be
specified as request parameter PARAM_PAGE, to properly handle usage of
the back button in a browser: In this case, a submission always contains
the correct page number, even if the user submitted from an old view.
The page can only be changed if it validates correctly, except if a
"dirty back" or "dirty forward" is allowed. At finish, all pages get
validated again to guarantee a consistent state.
Note that a validator's default validate method is not executed when using
this class! Rather, the
AbstractWizardFormController.validatePage implementation should call
special validateXXX methods that the validator needs to provide,
validating certain pieces of the object. These can be combined to validate
the elements of individual pages.
Note: Page numbering starts with 0, to be able to pass an array
consisting of the corresponding view names to the "pages" bean property.
author: Juergen Hoeller since: 25.04.2003 See Also: AbstractWizardFormController.setPages See Also: AbstractWizardFormController.validatePage See Also: AbstractWizardFormController.processFinish See Also: AbstractWizardFormController.processCancel |
Field Summary | |
final public static String | PARAM_CANCEL Parameter triggering the cancel action. | final public static String | PARAM_FINISH Parameter triggering the finish action. | final public static String | PARAM_PAGE Parameter specifying the current page as value. | final public static String | PARAM_TARGET Parameter specifying the target page,
appending the page number to the name. |
Method Summary | |
protected int | getCurrentPage(HttpServletRequest request) Return the current page number. | protected int | getInitialPage(HttpServletRequest request, Object command) Return the initial page of the wizard, that is, the page shown at wizard startup. | protected int | getInitialPage(HttpServletRequest request) Return the initial page of the wizard, that is, the page shown at wizard startup. | final public String | getPageAttribute() Return the name of the page attribute in the model. | final protected int | getPageCount() Return the number of wizard pages.
Useful to check whether the last page has been reached.
Note that a concrete wizard form controller might override
AbstractWizardFormController.getPageCount(HttpServletRequest,Object) to determine
the page count dynamically. | protected int | getPageCount(HttpServletRequest request, Object command) Return the page count for this wizard form controller. | protected String | getPageSessionAttributeName(HttpServletRequest request) Return the name of the HttpSession attribute that holds the page object
for this wizard form controller. | protected String | getPageSessionAttributeName() Return the name of the HttpSession attribute that holds the page object
for this wizard form controller.
Default is an internal name, of no relevance to applications, as the form
session attribute is not usually accessed directly. | final public String[] | getPages() Return the wizard pages, i.e. | protected int | getTargetPage(HttpServletRequest request, Object command, Errors errors, int currentPage) Return the target page specified in the request. | protected int | getTargetPage(HttpServletRequest request, int currentPage) Return the target page specified in the request.
The default implementation examines "_target" parameter (e.g. | protected String | getViewName(HttpServletRequest request, Object command, int page) Return the name of the view for the specified page of this wizard form controller. | protected ModelAndView | handleInvalidSubmit(HttpServletRequest request, HttpServletResponse response) Handle an invalid submit request, e.g. | final public boolean | isAllowDirtyBack() Return whether "dirty back" is allowed. | final public boolean | isAllowDirtyForward() Return whether "dirty forward" is allowed. | protected boolean | isCancelRequest(HttpServletRequest request) Determine whether the incoming request is a request to cancel the
processing of the current form.
By default, this method returns true if a parameter
matching the "_cancel" key is present in the request, otherwise it
returns false . | protected boolean | isFinishRequest(HttpServletRequest request) Determine whether the incoming request is a request to finish the
processing of the current form.
By default, this method returns true if a parameter
matching the "_finish" key is present in the request, otherwise it
returns false . | protected boolean | isFormSubmission(HttpServletRequest request) Consider an explicit finish or cancel request as a form submission too. | final protected void | onBindAndValidate(HttpServletRequest request, Object command, BindException errors) Calls page-specific onBindAndValidate method. | protected void | onBindAndValidate(HttpServletRequest request, Object command, BindException errors, int page) Callback for custom post-processing in terms of binding and validation. | protected void | postProcessPage(HttpServletRequest request, Object command, Errors errors, int page) Post-process the given page after binding and validation, potentially
updating its command object. | protected ModelAndView | processCancel(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) Template method for processing the cancel action of this wizard.
The default implementation throws a ServletException, saying that a cancel
operation is not supported by this controller. | abstract protected ModelAndView | processFinish(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) Template method for processing the final action of this wizard. | final protected ModelAndView | processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) Apply wizard workflow: finish, cancel, page change. | final protected Map | referenceData(HttpServletRequest request, Object command, Errors errors) Calls page-specific referenceData method. | protected Map | referenceData(HttpServletRequest request, Object command, Errors errors, int page) Create a reference data map for the given request, consisting of
bean name/bean instance pairs as expected by ModelAndView. | protected Map | referenceData(HttpServletRequest request, int page) Create a reference data map for the given request, consisting of
bean name/bean instance pairs as expected by ModelAndView. | final public void | setAllowDirtyBack(boolean allowDirtyBack) Set if "dirty back" is allowed, that is, if moving to a former wizard
page is allowed in case of validation errors for the current page. | final public void | setAllowDirtyForward(boolean allowDirtyForward) Set if "dirty forward" is allowed, that is, if moving to a later wizard
page is allowed in case of validation errors for the current page. | final public void | setPageAttribute(String pageAttribute) Set the name of the page attribute in the model, containing
an Integer with the current page number. | final public void | setPages(String[] pages) Set the wizard pages, i.e. | final protected ModelAndView | showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) Show first page as form view. | final protected ModelAndView | showPage(HttpServletRequest request, BindException errors, int page) Prepare the form model and view, including reference and error data,
for the given page. | protected void | validatePage(Object command, Errors errors, int page, boolean finish) Template method for custom validation logic for individual pages.
The default implementation calls
AbstractWizardFormController.validatePage(Object,Errors,int) .
Implementations will typically call fine-granular validateXXX
methods of this instance's Validator, combining them to validation of the
corresponding pages. | protected void | validatePage(Object command, Errors errors, int page) Template method for custom validation logic for individual pages. |
PARAM_CANCEL | final public static String PARAM_CANCEL(Code) | | Parameter triggering the cancel action.
Can be called from any wizard page!
|
PARAM_FINISH | final public static String PARAM_FINISH(Code) | | Parameter triggering the finish action.
Can be called from any wizard page!
|
PARAM_TARGET | final public static String PARAM_TARGET(Code) | | Parameter specifying the target page,
appending the page number to the name.
|
AbstractWizardFormController | public AbstractWizardFormController()(Code) | | Create a new AbstractWizardFormController.
"sessionForm" is automatically turned on, "validateOnBinding"
turned off, and "cacheSeconds" set to 0 by the base class
(-> no caching for all form controllers).
|
getInitialPage | protected int getInitialPage(HttpServletRequest request)(Code) | | Return the initial page of the wizard, that is, the page shown at wizard startup.
The default implementation returns 0 for first page.
Parameters: request - current HTTP request the initial page number |
getPageAttribute | final public String getPageAttribute()(Code) | | Return the name of the page attribute in the model.
|
getPageSessionAttributeName | protected String getPageSessionAttributeName()(Code) | | Return the name of the HttpSession attribute that holds the page object
for this wizard form controller.
Default is an internal name, of no relevance to applications, as the form
session attribute is not usually accessed directly. Can be overridden to use
an application-specific attribute name, which allows other code to access
the session attribute directly.
the name of the page session attribute See Also: AbstractWizardFormController.getFormSessionAttributeName See Also: javax.servlet.http.HttpSession.getAttribute |
getTargetPage | protected int getTargetPage(HttpServletRequest request, int currentPage)(Code) | | Return the target page specified in the request.
The default implementation examines "_target" parameter (e.g. "_target1").
Subclasses can override this for customized target page determination.
Parameters: request - current HTTP request Parameters: currentPage - the current page, to be returned as fallbackif no target page specified the page specified in the request, or current page if not found See Also: AbstractWizardFormController.PARAM_TARGET |
getViewName | protected String getViewName(HttpServletRequest request, Object command, int page)(Code) | | Return the name of the view for the specified page of this wizard form controller.
The default implementation takes the view name from the
AbstractWizardFormController.getPages() array.
Can be overridden to dynamically switch the page view or to return view names
for dynamically defined pages.
Parameters: request - current HTTP request Parameters: command - the command object as returned by formBackingObject the current page count See Also: AbstractWizardFormController.getPageCount |
isAllowDirtyBack | final public boolean isAllowDirtyBack()(Code) | | Return whether "dirty back" is allowed.
|
isAllowDirtyForward | final public boolean isAllowDirtyForward()(Code) | | Return whether "dirty forward" is allowed.
|
isCancelRequest | protected boolean isCancelRequest(HttpServletRequest request)(Code) | | Determine whether the incoming request is a request to cancel the
processing of the current form.
By default, this method returns true if a parameter
matching the "_cancel" key 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").
Parameters: request - current HTTP request See Also: AbstractWizardFormController.PARAM_CANCEL |
isFinishRequest | protected boolean isFinishRequest(HttpServletRequest request)(Code) | | Determine whether the incoming request is a request to finish the
processing of the current form.
By default, this method returns true if a parameter
matching the "_finish" key is present in the request, otherwise it
returns false . Subclasses may override this method
to provide custom logic to detect a finish request.
The parameter is recognized both when sent as a plain parameter
("_finish") or when triggered by an image button ("_finish.x").
Parameters: request - current HTTP request See Also: AbstractWizardFormController.PARAM_FINISH |
postProcessPage | protected void postProcessPage(HttpServletRequest request, Object command, Errors errors, int page) throws Exception(Code) | | Post-process the given page after binding and validation, potentially
updating its command object. The passed-in request might contain special
parameters sent by the page.
Only invoked when displaying another page or the same page again,
not when finishing or cancelling.
Parameters: request - current HTTP request Parameters: command - form object with request parameters bound onto it Parameters: errors - validation errors holder Parameters: page - number of page to post-process throws: Exception - in case of invalid state or arguments |
processCancel | protected ModelAndView processCancel(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception(Code) | | Template method for processing the cancel action of this wizard.
The default implementation throws a ServletException, saying that a cancel
operation is not supported by this controller. Thus, you do not need to
implement this template method if you do not support a cancel operation.
Call errors.getModel() to populate the ModelAndView model
with the command and the Errors instance, under the specified command name,
as expected by the "spring:bind" tag.
Parameters: request - current HTTP request Parameters: response - current HTTP response Parameters: command - form object with the current wizard state Parameters: errors - Errors instance containing errors the cancellation view throws: Exception - in case of invalid state or arguments See Also: org.springframework.validation.Errors See Also: org.springframework.validation.BindException.getModel |
referenceData | protected Map referenceData(HttpServletRequest request, Object command, Errors errors, int page) throws Exception(Code) | | Create a reference data map for the given request, consisting of
bean name/bean instance pairs as expected by ModelAndView.
The default implementation delegates to referenceData(HttpServletRequest, int).
Subclasses can override this to set reference data used in the view.
Parameters: request - current HTTP request Parameters: command - form object with request parameters bound onto it Parameters: errors - validation errors holder Parameters: page - current wizard page a Map with reference data entries, or null if none throws: Exception - in case of invalid state or arguments See Also: AbstractWizardFormController.referenceData(HttpServletRequest,int) See Also: ModelAndView |
referenceData | protected Map referenceData(HttpServletRequest request, int page) throws Exception(Code) | | Create a reference data map for the given request, consisting of
bean name/bean instance pairs as expected by ModelAndView.
The default implementation returns null .
Subclasses can override this to set reference data used in the view.
Parameters: request - current HTTP request Parameters: page - current wizard page a Map with reference data entries, or null if none throws: Exception - in case of invalid state or arguments See Also: ModelAndView |
setAllowDirtyBack | final public void setAllowDirtyBack(boolean allowDirtyBack)(Code) | | Set if "dirty back" is allowed, that is, if moving to a former wizard
page is allowed in case of validation errors for the current page.
Parameters: allowDirtyBack - if "dirty back" is allowed |
setAllowDirtyForward | final public void setAllowDirtyForward(boolean allowDirtyForward)(Code) | | Set if "dirty forward" is allowed, that is, if moving to a later wizard
page is allowed in case of validation errors for the current page.
Parameters: allowDirtyForward - if "dirty forward" is allowed |
setPageAttribute | final public void setPageAttribute(String pageAttribute)(Code) | | Set the name of the page attribute in the model, containing
an Integer with the current page number.
This will be necessary for single views rendering multiple view pages.
It also allows for specifying the optional "_page" parameter.
Parameters: pageAttribute - name of the page attribute See Also: AbstractWizardFormController.PARAM_PAGE |
setPages | final public void setPages(String[] pages)(Code) | | Set the wizard pages, i.e. the view names for the pages.
The array index is interpreted as page number.
Parameters: pages - view names for the pages |
showPage | final protected ModelAndView showPage(HttpServletRequest request, BindException errors, int page) throws Exception(Code) | | Prepare the form model and view, including reference and error data,
for the given page. Can be used in
AbstractWizardFormController.processFinish implementations,
to show the corresponding page in case of validation errors.
Parameters: request - current HTTP request Parameters: errors - validation errors holder Parameters: page - number of page to show the prepared form view throws: Exception - in case of invalid state or arguments |
validatePage | protected void validatePage(Object command, Errors errors, int page)(Code) | | Template method for custom validation logic for individual pages.
The default implementation is empty.
Implementations will typically call fine-granular validateXXX methods of this
instance's validator, combining them to validation of the corresponding pages.
The validator's default validate method will not be called by a
wizard form controller!
Parameters: command - form object with the current wizard state Parameters: errors - validation errors holder Parameters: page - number of page to validate See Also: org.springframework.validation.Validator.validate |
Methods inherited from org.springframework.web.servlet.mvc.AbstractFormController | protected Object currentFormObject(HttpServletRequest request, Object sessionFormObject) throws Exception(Code)(Java Doc) protected Object formBackingObject(HttpServletRequest request) throws Exception(Code)(Java Doc) final protected Object getCommand(HttpServletRequest request) throws Exception(Code)(Java Doc) final protected BindException getErrorsForNewForm(HttpServletRequest request) throws Exception(Code)(Java Doc) protected String getFormSessionAttributeName(HttpServletRequest request)(Code)(Java Doc) protected String getFormSessionAttributeName()(Code)(Java Doc) protected ModelAndView handleInvalidSubmit(HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc) protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc) final public boolean isBindOnNewForm()(Code)(Java Doc) protected boolean isFormSubmission(HttpServletRequest request)(Code)(Java Doc) final public boolean isSessionForm()(Code)(Java Doc) protected void onBindOnNewForm(HttpServletRequest request, Object command, BindException errors) throws Exception(Code)(Java Doc) protected void onBindOnNewForm(HttpServletRequest request, Object command) throws Exception(Code)(Java Doc) abstract protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception(Code)(Java Doc) protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception(Code)(Java Doc) final public void setBindOnNewForm(boolean bindOnNewForm)(Code)(Java Doc) final public void setSessionForm(boolean sessionForm)(Code)(Java Doc) abstract protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception(Code)(Java Doc) final protected ModelAndView showForm(HttpServletRequest request, BindException errors, String viewName) throws Exception(Code)(Java Doc) final protected ModelAndView showForm(HttpServletRequest request, BindException errors, String viewName, Map controlModel) throws Exception(Code)(Java Doc) final protected ModelAndView showNewForm(HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc)
|
Fields inherited from org.springframework.web.servlet.mvc.BaseCommandController | final public static String DEFAULT_COMMAND_NAME(Code)(Java Doc)
|
Methods inherited from org.springframework.web.servlet.mvc.BaseCommandController | final protected ServletRequestDataBinder bindAndValidate(HttpServletRequest request, Object command) throws Exception(Code)(Java Doc) final protected boolean checkCommand(Object command)(Code)(Java Doc) protected ServletRequestDataBinder createBinder(HttpServletRequest request, Object command) throws Exception(Code)(Java Doc) final protected Object createCommand() throws Exception(Code)(Java Doc) final public BindingErrorProcessor getBindingErrorProcessor()(Code)(Java Doc) protected Object getCommand(HttpServletRequest request) throws Exception(Code)(Java Doc) final public Class getCommandClass()(Code)(Java Doc) final public String getCommandName()(Code)(Java Doc) final public MessageCodesResolver getMessageCodesResolver()(Code)(Java Doc) final public PropertyEditorRegistrar[] getPropertyEditorRegistrars()(Code)(Java Doc) final public Validator getValidator()(Code)(Java Doc) final public Validator[] getValidators()(Code)(Java Doc) protected void initApplicationContext()(Code)(Java Doc) protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception(Code)(Java Doc) final public boolean isValidateOnBinding()(Code)(Java Doc) protected void onBind(HttpServletRequest request, Object command, BindException errors) throws Exception(Code)(Java Doc) protected void onBind(HttpServletRequest request, Object command) throws Exception(Code)(Java Doc) protected void onBindAndValidate(HttpServletRequest request, Object command, BindException errors) throws Exception(Code)(Java Doc) final protected void prepareBinder(ServletRequestDataBinder binder)(Code)(Java Doc) final public void setBindingErrorProcessor(BindingErrorProcessor bindingErrorProcessor)(Code)(Java Doc) final public void setCommandClass(Class commandClass)(Code)(Java Doc) final public void setCommandName(String commandName)(Code)(Java Doc) final public void setMessageCodesResolver(MessageCodesResolver messageCodesResolver)(Code)(Java Doc) final public void setPropertyEditorRegistrar(PropertyEditorRegistrar propertyEditorRegistrar)(Code)(Java Doc) final public void setPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars)(Code)(Java Doc) final public void setValidateOnBinding(boolean validateOnBinding)(Code)(Java Doc) final public void setValidator(Validator validator)(Code)(Java Doc) final public void setValidators(Validator[] validators)(Code)(Java Doc) protected boolean suppressBinding(HttpServletRequest request)(Code)(Java Doc) protected boolean suppressValidation(HttpServletRequest request, Object command, BindException errors)(Code)(Java Doc) protected boolean suppressValidation(HttpServletRequest request, Object command)(Code)(Java Doc) protected boolean suppressValidation(HttpServletRequest request)(Code)(Java Doc) protected boolean useDirectFieldAccess()(Code)(Java Doc)
|
|
|