站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.1.0 API 文档英文版

AbstractWizardFormController (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版


The Spring Framework

org.springframework.web.portlet.mvc
Class AbstractWizardFormController

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.portlet.context.PortletApplicationObjectSupport
          extended by org.springframework.web.portlet.handler.PortletContentGenerator
              extended by org.springframework.web.portlet.mvc.AbstractController
                  extended by org.springframework.web.portlet.mvc.BaseCommandController
                      extended by org.springframework.web.portlet.mvc.AbstractFormController
                          extended by org.springframework.web.portlet.mvc.AbstractWizardFormController
All Implemented Interfaces:
ApplicationContextAware, PortletContextAware, Controller

public abstract class AbstractWizardFormController
extends AbstractFormController

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 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 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.

Parameters indicated with setPassRenderParameters will be present for each page. If there are render parameters you need in renderFinish or renderCancel, then you need to pass those forward from the processFinish or processCancel methods, respectively.

Since:
2.0
Author:
Juergen Hoeller, John A. Lewis
See Also:
setPages(java.lang.String[]), validatePage(java.lang.Object, org.springframework.validation.Errors, int, boolean), processFinish(javax.portlet.ActionRequest, javax.portlet.ActionResponse, java.lang.Object, org.springframework.validation.BindException), processCancel(javax.portlet.ActionRequest, javax.portlet.ActionResponse, java.lang.Object, org.springframework.validation.BindException)

Field Summary
static String PARAM_CANCEL
          Parameter triggering the cancel action.
static String PARAM_FINISH
          Parameter triggering the finish action.
static String PARAM_PAGE
          Parameter specifying the current page as value.
static String PARAM_TARGET
          Parameter specifying the target page, appending the page number to the name.
 
Fields inherited from class org.springframework.web.portlet.mvc.BaseCommandController
DEFAULT_COMMAND_NAME
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
AbstractWizardFormController()
          Create a new AbstractWizardFormController.
 
Method Summary
protected  int getCurrentPage(PortletRequest request)
          Return the current page number.
protected  int getInitialPage(PortletRequest request)
          Return the initial page of the wizard, i.e. the page shown at wizard startup.
protected  int getInitialPage(PortletRequest request, Object command)
          Return the initial page of the wizard, i.e. the page shown at wizard startup.
 String getPageAttribute()
          Return the name of the page attribute in the model.
protected  int getPageCount()
          Return the number of wizard pages.
protected  int getPageCount(PortletRequest request, Object command)
          Return the page count for this wizard form controller.
 String[] getPages()
          Return the wizard pages, i.e. the view names for the pages.
protected  String getPageSessionAttributeName()
          Return the name of the PortletSession attribute that holds the page object for this wizard form controller.
protected  String getPageSessionAttributeName(PortletRequest request)
          Return the name of the PortletSession attribute that holds the page object for this wizard form controller.
protected  int getTargetPage(PortletRequest request, int currentPage)
          Return the target page specified in the request.
protected  int getTargetPage(PortletRequest request, Object command, Errors errors, int currentPage)
          Return the target page specified in the request.
protected  String getViewName(PortletRequest request, Object command, int page)
          Return the name of the view for the specified page of this wizard form controller.
protected  void handleInvalidSubmit(ActionRequest request, ActionResponse response)
          Handle an invalid submit request, e.g. when in session form mode but no form object was found in the session (like in case of an invalid resubmit by the browser).
 boolean isAllowDirtyBack()
          Return whether "dirty back" is allowed.
 boolean isAllowDirtyForward()
          Return whether "dirty forward" is allowed.
protected  boolean isCancelRequest(PortletRequest request)
          Determine whether the incoming request is a request to cancel the processing of the current form.
protected  boolean isFinishRequest(PortletRequest request)
          Determine whether the incoming request is a request to finish the processing of the current form.
protected  boolean isFormSubmission(PortletRequest request)
          Consider an explicit finish or cancel request as a form submission too.
protected  void onBindAndValidate(PortletRequest request, Object command, BindException errors)
          Calls page-specific onBindAndValidate method.
protected  void onBindAndValidate(PortletRequest request, Object command, BindException errors, int page)
          Callback for custom post-processing in terms of binding and validation.
protected  void postProcessPage(ActionRequest request, Object command, Errors errors, int page)
          Post-process the given page after binding and validation, potentially updating its command object.
protected  void processCancel(ActionRequest request, ActionResponse response, Object command, BindException errors)
          Template method for the action phase of the cancel action of this wizard.
protected  void processFinish(ActionRequest request, ActionResponse response, Object command, BindException errors)
          Template method for the action phase of the finish action of this wizard.
protected  void processFormSubmission(ActionRequest request, ActionResponse response, Object command, BindException errors)
          Apply wizard workflow: finish, cancel, page change.
protected  Map referenceData(PortletRequest request, 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(PortletRequest request, Object command, Errors errors)
          Calls page-specific referenceData method.
protected  Map referenceData(PortletRequest 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  ModelAndView renderCancel(RenderRequest request, RenderResponse response, Object command, BindException errors)
          Template method for the render phase of the cancel action of this wizard.
protected  ModelAndView renderFinish(RenderRequest request, RenderResponse response, Object command, BindException errors)
          Template method for the render phase of the finish action of this wizard.
protected  ModelAndView renderFormSubmission(RenderRequest request, RenderResponse response, Object command, BindException errors)
          Apply wizard workflow: finish, cancel, page change.
protected  ModelAndView renderInvalidSubmit(RenderRequest request, RenderResponse response)
          Handle an invalid submit request, e.g. when in session form mode but no form object was found in the session (like in case of an invalid resubmit by the browser).
 void setAllowDirtyBack(boolean allowDirtyBack)
          Set if "dirty back" is allowed, i.e. if moving to a former wizard page is allowed in case of validation errors for the current page.
 void setAllowDirtyForward(boolean allowDirtyForward)
          Set if "dirty forward" is allowed, i.e. if moving to a later wizard page is allowed in case of validation errors for the current page.
protected  void setCancelRenderParameter(ActionRequest request, ActionResponse response)
          Pass the the parameter that indicates a cancel request forward to the render phase.
protected  void setFinishRenderParameter(ActionRequest request, ActionResponse response)
          Pass the the parameter that indicates a finish request forward to the render phase.
 void setPageAttribute(String pageAttribute)
          Set the name of the page attribute in the model, containing an Integer with the current page number.
protected  void setPageRenderParameter(ActionResponse response, int page)
          Pass the page number to the render phase by setting a render parameter.
 void setPages(String[] pages)
          Set the wizard pages, i.e. the view names for the pages.
protected  void setTargetRenderParameter(ActionRequest request, ActionResponse response)
          Pass the the parameter that indicates the target page of the request forward to the render phase.
protected  ModelAndView showForm(RenderRequest request, RenderResponse response, BindException errors)
          Show first page as form view.
protected  ModelAndView showPage(RenderRequest 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)
          Template method for custom validation logic for individual pages.
protected  void validatePage(Object command, Errors errors, int page, boolean finish)
          Template method for custom validation logic for individual pages.
 
Methods inherited from class org.springframework.web.portlet.mvc.AbstractFormController
formBackingObject, getCommand, getErrorsForNewForm, getFormSessionAttributeName, getFormSessionAttributeName, getFormSubmitParameterName, getInvalidSubmitParameterName, getRenderParameters, handleActionRequestInternal, handleRenderRequestInternal, isBindOnNewForm, isInvalidSubmission, isRedirectAction, isSessionForm, onBindOnNewForm, onBindOnNewForm, passRenderParameters, setBindOnNewForm, setFormSubmit, setInvalidSubmit, setRedirectAction, setRenderParameters, setSessionForm, showForm, showForm, showNewForm
 
Methods inherited from class org.springframework.web.portlet.mvc.BaseCommandController
bindAndValidate, checkCommand, createBinder, createCommand, getBindingErrorProcessor, getCommandClass, getCommandName, getMessageCodesResolver, getPropertyEditorRegistrars, getRenderCommand, getRenderCommandSessionAttributeName, getRenderErrors, getRenderErrorsSessionAttributeName, getValidator, getValidators, initApplicationContext, initBinder, isValidateOnBinding, onBind, onBind, prepareBinder, setBindingErrorProcessor, setCommandClass, setCommandName, setMessageCodesResolver, setPropertyEditorRegistrar, setPropertyEditorRegistrars, setRenderCommandAndErrors, setValidateOnBinding, setValidator, setValidators, suppressBinding, suppressValidation, useDirectFieldAccess
 
Methods inherited from class org.springframework.web.portlet.mvc.AbstractController
handleActionRequest, handleRenderRequest, isRenderWhenMinimized, isSynchronizeOnSession, setRenderWhenMinimized, setSynchronizeOnSession
 
Methods inherited from class org.springframework.web.portlet.handler.PortletContentGenerator
applyCacheSeconds, cacheForSeconds, check, checkAndPrepare, checkAndPrepare, getCacheSeconds, isRequireSession, preventCaching, setCacheSeconds, setRequireSession
 
Methods inherited from class org.springframework.web.portlet.context.PortletApplicationObjectSupport
getPortletContext, getTempDir, isContextRequired, setPortletContext
 
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
 

Field Detail

PARAM_FINISH

public static final String PARAM_FINISH
Parameter triggering the finish action. Can be called from any wizard page!

See Also:
Constant Field Values

PARAM_CANCEL

public static final String PARAM_CANCEL
Parameter triggering the cancel action. Can be called from any wizard page!

See Also:
Constant Field Values

PARAM_TARGET

public static final String PARAM_TARGET
Parameter specifying the target page, appending the page number to the name.

See Also:
Constant Field Values

PARAM_PAGE

public static final String PARAM_PAGE
Parameter specifying the current page as value. Not necessary on form pages, but allows to properly handle usage of the back button.

See Also:
setPageAttribute(java.lang.String), Constant Field Values
Constructor Detail

AbstractWizardFormController

public AbstractWizardFormController()
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).

Method Detail

setPages

public final void setPages(String[] pages)
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

getPages

public final String[] getPages()
Return the wizard pages, i.e. the view names for the pages. The array index corresponds to the page number.

Note that a concrete wizard form controller might override getViewName(PortletRequest, Object, int) to determine the view name for each page dynamically.

See Also:
getViewName(PortletRequest, Object, int)

getPageCount

protected final 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 getPageCount(PortletRequest, Object) to determine the page count dynamically.

See Also:
getPageCount(PortletRequest, Object)

setPageAttribute

public final void setPageAttribute(String pageAttribute)
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:
PARAM_PAGE

getPageAttribute

public final String getPageAttribute()
Return the name of the page attribute in the model.


setAllowDirtyBack

public final void setAllowDirtyBack(boolean allowDirtyBack)
Set if "dirty back" is allowed, i.e. 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

isAllowDirtyBack

public final boolean isAllowDirtyBack()
Return whether "dirty back" is allowed.


setAllowDirtyForward

public final void setAllowDirtyForward(boolean allowDirtyForward)
Set if "dirty forward" is allowed, i.e. 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

isAllowDirtyForward

public final boolean isAllowDirtyForward()
Return whether "dirty forward" is allowed.


onBindAndValidate

protected final void onBindAndValidate(PortletRequest request,
                                       Object command,
                                       BindException errors)
                                throws Exception
Calls page-specific onBindAndValidate method.

Overrides:
onBindAndValidate in class BaseCommandController
Parameters:
request - current portlet request
command - the command object, still allowing for further binding
errors - validation errors holder, allowing for additional custom validation
Throws:
Exception - in case of invalid state or arguments
See Also:
BaseCommandController.bindAndValidate(javax.portlet.PortletRequest, java.lang.Object), Errors

onBindAndValidate

protected void onBindAndValidate(PortletRequest request,
                                 Object command,
                                 BindException errors,
                                 int page)
                          throws Exception
Callback for custom post-processing in terms of binding and validation. Called on each submit, after standard binding but before page-specific validation of this wizard form controller.

Note: AbstractWizardFormController does not perform standard validation on binding but rather applies page-specific validation on processing the form submission.

Parameters:
request - current portlet request
command - bound command
errors - Errors instance for additional custom validation
page - current wizard page
Throws:
Exception - in case of invalid state or arguments
See Also:
BaseCommandController.bindAndValidate(javax.portlet.PortletRequest, java.lang.Object), processFormSubmission(javax.portlet.ActionRequest, javax.portlet.ActionResponse, java.lang.Object, org.springframework.validation.BindException), Errors

isFormSubmission

protected boolean isFormSubmission(PortletRequest request)
Consider an explicit finish or cancel request as a form submission too.

Overrides:
isFormSubmission in class AbstractFormController
Parameters:
request - current request
Returns:
if the request represents a form submission
See Also:
isFinishRequest(PortletRequest), isCancelRequest(PortletRequest)

referenceData

protected final Map referenceData(PortletRequest request,
                                  Object command,
                                  Errors errors)
                           throws Exception
Calls page-specific referenceData method.

Overrides:
referenceData in class AbstractFormController
Parameters:
request - current render request
command - form object with request parameters bound onto it
errors - validation errors holder
Returns:
a Map with reference data entries, or null if none
Throws:
Exception - in case of invalid state or arguments
See Also:
ModelAndView

referenceData

protected Map referenceData(PortletRequest request,
                            Object command,
                            Errors errors,
                            int page)
                     throws Exception
Create a reference data map for the given request, consisting of bean name/bean instance pairs as expected by ModelAndView.

Default implementation delegates to referenceData(HttpServletRequest, int). Subclasses can override this to set reference data used in the view.

Parameters:
request - current portlet request
command - form object with request parameters bound onto it
errors - validation errors holder
page - current wizard page
Returns:
a Map with reference data entries, or null if none
Throws:
Exception - in case of invalid state or arguments
See Also:
referenceData(PortletRequest, int), ModelAndView

referenceData

protected Map referenceData(PortletRequest request,
                            int page)
                     throws Exception
Create a reference data map for the given request, consisting of bean name/bean instance pairs as expected by ModelAndView.

Default implementation returns null. Subclasses can override this to set reference data used in the view.

Parameters:
request - current portlet request
page - current wizard page
Returns:
a Map with reference data entries, or null if none
Throws:
Exception - in case of invalid state or arguments
See Also:
ModelAndView

showForm

protected final ModelAndView showForm(RenderRequest request,
                                      RenderResponse response,
                                      BindException errors)
                               throws Exception
Show first page as form view.

Specified by:
showForm in class AbstractFormController
Parameters:
request - current render request
response - current render response
errors - validation errors holder
Returns:
the prepared form view, or null if handled directly
Throws:
Exception - in case of invalid state or arguments
See Also:
AbstractFormController.showForm(RenderRequest, BindException, String), Errors, BindException.getModel(), AbstractFormController.referenceData(PortletRequest, Object, Errors), SimpleFormController.setFormView(java.lang.String)

showPage

protected final ModelAndView showPage(RenderRequest request,
                                      BindException errors,
                                      int page)
                               throws Exception
Prepare the form model and view, including reference and error data, for the given page. Can be used in processFinish implementations, to show the corresponding page in case of validation errors.

Parameters:
request - current portlet render request
errors - validation errors holder
page - number of page to show
Returns:
the prepared form view
Throws:
Exception - in case of invalid state or arguments

getPageCount

protected int getPageCount(PortletRequest request,
                           Object command)
Return the page count for this wizard form controller. Default implementation delegates to getPageCount().

Can be overridden to dynamically adapt the page count.

Parameters:
request - current portlet request
command - the command object as returned by formBackingObject
Returns:
the current page count
See Also:
getPageCount()

getViewName

protected String getViewName(PortletRequest request,
                             Object command,
                             int page)
Return the name of the view for the specified page of this wizard form controller. Default implementation takes the view name from the getPages() array.

Can be overridden to dynamically switch the page view or to return view names for dynamically defined pages.

Parameters:
request - current portlet request
command - the command object as returned by formBackingObject
Returns:
the current page count
See Also:
getPageCount()

getInitialPage

protected int getInitialPage(PortletRequest request,
                             Object command)
Return the initial page of the wizard, i.e. the page shown at wizard startup. Default implementation delegates to getInitialPage(PortletRequest).

Parameters:
request - current portlet request
command - the command object as returned by formBackingObject
Returns:
the initial page number
See Also:
getInitialPage(PortletRequest), AbstractFormController.formBackingObject(javax.portlet.PortletRequest)

getInitialPage

protected int getInitialPage(PortletRequest request)
Return the initial page of the wizard, i.e. the page shown at wizard startup. Default implementation returns 0 for first page.

Parameters:
request - current portlet request
Returns:
the initial page number

getPageSessionAttributeName

protected String getPageSessionAttributeName(PortletRequest request)
Return the name of the PortletSession attribute that holds the page object for this wizard form controller.

Default implementation delegates to the getPageSessionAttributeName version without arguments.

Parameters:
request - current portlet request
Returns:
the name of the form session attribute, or null if not in session form mode
See Also:
getPageSessionAttributeName(javax.portlet.PortletRequest), AbstractFormController.getFormSessionAttributeName(javax.portlet.PortletRequest), PortletSession.getAttribute(java.lang.String)

getPageSessionAttributeName

protected String getPageSessionAttributeName()
Return the name of the PortletSession 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.

Returns:
the name of the page session attribute
See Also:
AbstractFormController.getFormSessionAttributeName(javax.portlet.PortletRequest), PortletSession.getAttribute(java.lang.String)

setPageRenderParameter

protected void setPageRenderParameter(ActionResponse response,
                                      int page)
Pass the page number to the render phase by setting a render parameter. This method may not be called when the action calls ActionResponse.sendRedirect(String).

Parameters:
response - the current action response
page - the page number
See Also:
ActionResponse.setRenderParameter(java.lang.String, java.lang.String)

setTargetRenderParameter

protected void setTargetRenderParameter(ActionRequest request,
                                        ActionResponse response)
Pass the the parameter that indicates the target page of the request forward to the render phase. If the getTargetPage method was overridden, this may need to be overriden as well.

Parameters:
request - the current action request
response - the current action response
See Also:
PARAM_TARGET, getTargetPage(PortletRequest, int), getTargetPage(PortletRequest, Object, Errors, int), ActionResponse.setRenderParameter(java.lang.String, java.lang.String)

setFinishRenderParameter

protected void setFinishRenderParameter(ActionRequest request,
                                        ActionResponse response)
Pass the the parameter that indicates a finish request forward to the render phase. If the isFinishRequest method was overridden, this may need to be overriden as well.

Parameters:
request - the current action request
response - the current action response
See Also:
PARAM_FINISH, isFinishRequest(javax.portlet.PortletRequest), ActionResponse.setRenderParameter(java.lang.String, java.lang.String)

setCancelRenderParameter

protected void setCancelRenderParameter(ActionRequest request,
                                        ActionResponse response)
Pass the the parameter that indicates a cancel request forward to the render phase. If the isCancelRequest method was overridden, this may need to be overriden as well.

Parameters:
request - the current action request
response - the current action response
See Also:
PARAM_CANCEL, isCancelRequest(javax.portlet.PortletRequest), ActionResponse.setRenderParameter(java.lang.String, java.lang.String)

renderInvalidSubmit

protected ModelAndView renderInvalidSubmit(RenderRequest request,
                                           RenderResponse response)
                                    throws Exception
Handle an invalid submit request, e.g. when in session form mode but no form object was found in the session (like in case of an invalid resubmit by the browser).

Default implementation for wizard form controllers simply shows the initial page of a new wizard form. If you want to show some "invalid submit" message, you need to override this method.

Overrides:
renderInvalidSubmit in class AbstractFormController
Parameters:
request - current portlet render request
response - current portlet render response
Returns:
a prepared view, or null if handled directly
Throws:
Exception - in case of errors
See Also:
AbstractFormController.showNewForm(javax.portlet.RenderRequest, javax.portlet.RenderResponse), AbstractFormController.setBindOnNewForm(boolean), handleInvalidSubmit(javax.portlet.ActionRequest, javax.portlet.ActionResponse)

handleInvalidSubmit

protected void handleInvalidSubmit(ActionRequest request,
                                   ActionResponse response)
                            throws Exception
Handle an invalid submit request, e.g. when in session form mode but no form object was found in the session (like in case of an invalid resubmit by the browser).

Default implementation for wizard form controllers simply shows the initial page of a new wizard form, so here in the action phase this method does nothing. If you want to take some action on an invalid submit, you need to override this method.

Overrides:
handleInvalidSubmit in class AbstractFormController
Parameters:
request - current portlet action request
response - current portlet action response
Throws:
Exception - in case of errors
See Also:
renderInvalidSubmit(javax.portlet.RenderRequest, javax.portlet.RenderResponse)

renderFormSubmission

protected final ModelAndView renderFormSubmission(RenderRequest request,
                                                  RenderResponse response,
                                                  Object command,
                                                  BindException errors)
                                           throws Exception
Apply wizard workflow: finish, cancel, page change.

Specified by:
renderFormSubmission in class AbstractFormController
Parameters:
request - current render request
response - current render response
command - form object with request parameters bound onto it
errors - errors holder
Returns:
the prepared model and view, or null
Throws:
Exception - in case of errors
See Also:
processFormSubmission(javax.portlet.ActionRequest, javax.portlet.ActionResponse, java.lang.Object, org.springframework.validation.BindException)

processFormSubmission

protected final void processFormSubmission(ActionRequest request,
                                           ActionResponse response,
                                           Object command,
                                           BindException errors)
                                    throws Exception
Apply wizard workflow: finish, cancel, page change.

Specified by:
processFormSubmission in class AbstractFormController
Parameters:
request - current action request
response - current action response
command - form object with request parameters bound onto it
errors - errors holder (subclass can add errors if it wants to)
Throws:
Exception - in case of errors
See Also:
renderFormSubmission(javax.portlet.RenderRequest, javax.portlet.RenderResponse, java.lang.Object, org.springframework.validation.BindException)

getCurrentPage

protected int getCurrentPage(PortletRequest request)
Return the current page number. Used by processFormSubmission.

The default implementation checks the page session attribute. Subclasses can override this for customized page determination.

See Also:
processFormSubmission(javax.portlet.ActionRequest, javax.portlet.ActionResponse, java.lang.Object, org.springframework.validation.BindException), getPageSessionAttributeName(javax.portlet.PortletRequest)

isFinishRequest

protected boolean isFinishRequest(PortletRequest 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. 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 portlet request
See Also:
PARAM_FINISH

isCancelRequest

protected boolean isCancelRequest(PortletRequest 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. 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 portlet request
See Also:
PARAM_CANCEL

getTargetPage

protected int getTargetPage(PortletRequest request,
                            Object command,
                            Errors errors,
                            int currentPage)
Return the target page specified in the request.

Default implementation delegates to getTargetPage(PortletRequest, int). Subclasses can override this for customized target page determination.

Parameters:
request - current portlet request
command - form object with request parameters bound onto it
errors - validation errors holder
currentPage - the current page, to be returned as fallback if no target page specified
Returns:
the page specified in the request, or current page if not found
See Also:
getTargetPage(PortletRequest, int)

getTargetPage

protected int getTargetPage(PortletRequest request,
                            int currentPage)
Return the target page specified in the request.

Default implementation examines "_target" parameter (e.g. "_target1"). Subclasses can override this for customized target page determination.

Parameters:
request - current portlet request
currentPage - the current page, to be returned as fallback if no target page specified
Returns:
the page specified in the request, or current page if not found
See Also:
PARAM_TARGET

validatePage

protected void validatePage(Object command,
                            Errors errors,
                            int page,
                            boolean finish)
Template method for custom validation logic for individual pages. Default implementation calls validatePage(command, errors, page).

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
errors - validation errors holder
page - number of page to validate
finish - whether this method is called during final revalidation on finish (else, it is called for validating the current page)
See Also:
validatePage(Object, Errors, int), Validator.validate(java.lang.Object, org.springframework.validation.Errors)

validatePage

protected void validatePage(Object command,
                            Errors errors,
                            int page)
Template method for custom validation logic for individual pages. 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
errors - validation errors holder
page - number of page to validate
See Also:
Validator.validate(java.lang.Object, org.springframework.validation.Errors)

postProcessPage

protected void postProcessPage(ActionRequest request,
                               Object command,
                               Errors errors,
                               int page)
                        throws Exception
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 action request
command - form object with request parameters bound onto it
errors - validation errors holder
page - number of page to post-process
Throws:
Exception - in case of invalid state or arguments

renderFinish

protected ModelAndView renderFinish(RenderRequest request,
                                    RenderResponse response,
                                    Object command,
                                    BindException errors)
                             throws Exception
Template method for the render phase of the finish action of this wizard.

Default implementation throws a PortletException, saying that a finish render request is not supported by this controller. Thus, you do not need to implement this template method if you do not need to render after a finish.

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 portlet render request
response - current portlet render response
command - form object with the current wizard state
errors - validation errors holder
Returns:
the finish view
Throws:
Exception - in case of invalid state or arguments
See Also:
processFinish(javax.portlet.ActionRequest, javax.portlet.ActionResponse, java.lang.Object, org.springframework.validation.BindException), Errors, BindException.getModel()

processFinish

protected void processFinish(ActionRequest request,
                             ActionResponse response,
                             Object command,
                             BindException errors)
                      throws Exception
Template method for the action phase of the finish action of this wizard.

Default implementation throws a PortletException, saying that a finish action request is not supported by this controller. You will almost certainly need to override this method.

Parameters:
request - current portlet action request
response - current portlet action response
command - form object with the current wizard state
errors - validation errors holder
Throws:
Exception - in case of invalid state or arguments
See Also:
renderFinish(javax.portlet.RenderRequest, javax.portlet.RenderResponse, java.lang.Object, org.springframework.validation.BindException), Errors

renderCancel

protected ModelAndView renderCancel(RenderRequest request,
                                    RenderResponse response,
                                    Object command,
                                    BindException errors)
                             throws Exception
Template method for the render phase of the cancel action of this wizard.

Default implementation throws a PortletException, saying that a cancel render request 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 portlet render request
response - current portlet render response
command - form object with the current wizard state
errors - Errors instance containing errors
Returns:
the cancellation view
Throws:
Exception - in case of invalid state or arguments
See Also:
processCancel(javax.portlet.ActionRequest, javax.portlet.ActionResponse, java.lang.Object, org.springframework.validation.BindException), Errors, BindException.getModel()

processCancel

protected void processCancel(ActionRequest request,
                             ActionResponse response,
                             Object command,
                             BindException errors)
                      throws Exception
Template method for the action phase of the cancel action of this wizard.

Default implementation throws a PortletException, saying that a cancel action request is not supported by this controller. Thus, you do not need to implement this template method if you do not support a cancel operation.

Parameters:
request - current portlet action request
response - current portlet action response
command - form object with the current wizard state
errors - Errors instance containing errors
Throws:
Exception - in case of invalid state or arguments
See Also:
renderCancel(javax.portlet.RenderRequest, javax.portlet.RenderResponse, java.lang.Object, org.springframework.validation.BindException), Errors

The Spring Framework

Copyright © 2002-2007 The Spring Framework.