|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--com.interface21.context.support.ApplicationObjectSupport
|
+--com.interface21.web.servlet.mvc.WebContentGenerator
|
+--com.interface21.web.servlet.mvc.AbstractController
|
+--com.interface21.web.servlet.mvc.BaseCommandController
|
+--com.interface21.web.servlet.mvc.AbstractFormController
|
+--com.interface21.web.servlet.mvc.AbstractWizardFormController
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 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 hand an array consisting of the respective view names to setPages.
setPages(java.lang.String[]),
validatePage(java.lang.Object, com.interface21.validation.Errors, int),
processFinish(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, com.interface21.validation.BindException),
processCancel(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, com.interface21.validation.BindException)| Field Summary | |
static java.lang.String |
PARAM_CANCEL
Parameter triggering the cancel action. |
static java.lang.String |
PARAM_FINISH
Parameter triggering the finish action. |
static java.lang.String |
PARAM_TARGET
Parameter specifying the target page, appending the page number to the name. |
| Fields inherited from class com.interface21.web.servlet.mvc.BaseCommandController |
DEFAULT_BEAN_NAME |
| Fields inherited from class com.interface21.context.support.ApplicationObjectSupport |
logger |
| Constructor Summary | |
AbstractWizardFormController()
Create a new AbstractWizardFormController. |
|
| Method Summary | |
protected int |
getCurrentPage(javax.servlet.http.HttpServletRequest request)
Return the current page number. |
protected int |
getInitialPage(javax.servlet.http.HttpServletRequest request)
Return the initial page of the wizard, i.e. the page shown at wizard startup. |
protected java.lang.String |
getPageSessionAttributeName()
Return the name of the session attribute that holds the page object for this controller. |
protected void |
onBindAndValidate(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
BindException errors)
Call page-specific onBindAndValidate method. |
protected void |
onBindAndValidate(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
BindException errors,
int page)
Callback for custom postprocessing in terms of binding and validation. |
protected abstract ModelAndView |
processCancel(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object command,
BindException errors)
Template method for processing the cancel action of this wizard. |
protected abstract ModelAndView |
processFinish(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object command,
BindException errors)
Template method for processing the final action of this wizard. |
protected ModelAndView |
processSubmit(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object command,
BindException errors)
Apply wizard workflow: finish, cancel, page change. |
protected java.util.Map |
referenceData(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
Errors errors)
Call page-specific referenceData method. |
protected java.util.Map |
referenceData(javax.servlet.http.HttpServletRequest request,
java.lang.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. |
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. |
void |
setPageAttribute(java.lang.String pageAttribute)
Set the name of the page attribute in the model, containing an Integer with the current page number. |
void |
setPages(java.lang.String[] pages)
Set the wizard pages, i.e. the view names for the pages. |
protected ModelAndView |
showForm(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
BindException errors)
Show first page as form view. |
protected ModelAndView |
showPage(javax.servlet.http.HttpServletRequest request,
BindException errors,
int page)
Prepare the form model and view, including reference and error data, for the given page. |
protected abstract void |
validatePage(java.lang.Object command,
Errors errors,
int page)
Template method for custom validation logic for individual pages. |
| Methods inherited from class com.interface21.web.servlet.mvc.AbstractFormController |
formBackingObject, getFormSessionAttributeName, handleInvalidSubmit, handleRequestInternal, isBindOnNewForm, isFormSubmission, isSessionForm, setBindOnNewForm, setSessionForm, showForm, showForm, showNewForm, userObject |
| Methods inherited from class com.interface21.web.servlet.mvc.BaseCommandController |
bindAndValidate, checkCommand, createBinder, createCommand, getBeanName, getCommandClass, getValidator, initBinder, isValidateOnBinding, setBeanName, setCommandClass, setValidateOnBinding, setValidator |
| Methods inherited from class com.interface21.web.servlet.mvc.AbstractController |
handleRequest, setCacheSeconds, setRequireSession, setSupportedMethods |
| Methods inherited from class com.interface21.web.servlet.mvc.WebContentGenerator |
cacheForSeconds, preventCaching, setUseExpiresHeader |
| Methods inherited from class com.interface21.context.support.ApplicationObjectSupport |
getApplicationContext, initApplicationContext, setApplicationContext |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String PARAM_FINISH
public static final java.lang.String PARAM_CANCEL
public static final java.lang.String PARAM_TARGET
| Constructor Detail |
public AbstractWizardFormController()
| Method Detail |
public final void setPages(java.lang.String[] pages)
pages - view names for the pagespublic final void setPageAttribute(java.lang.String pageAttribute)
pageAttribute - name of the page attributepublic final void setAllowDirtyBack(boolean allowDirtyBack)
allowDirtyBack - if "dirty back" is allowedpublic final void setAllowDirtyForward(boolean allowDirtyForward)
allowDirtyForward - if "dirty forward" is allowed
protected final void onBindAndValidate(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
BindException errors)
throws javax.servlet.ServletException
onBindAndValidate in class BaseCommandControllercom.interface21.web.servlet.mvc.BaseCommandControllerrequest - current HTTP requestcommand - bound commanderrors - binder for additional custom validationjavax.servlet.ServletException - in case of invalid state or argumentsBaseCommandController.bindAndValidate(javax.servlet.http.HttpServletRequest, java.lang.Object)
protected void onBindAndValidate(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
BindException errors,
int page)
throws javax.servlet.ServletException
request - current HTTP requestcommand - bound commanderrors - binder for additional custom validationpage - current wizard pagejavax.servlet.ServletException - in case of invalid state or argumentsBaseCommandController.bindAndValidate(javax.servlet.http.HttpServletRequest, java.lang.Object)
protected final java.util.Map referenceData(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
Errors errors)
throws javax.servlet.ServletException
referenceData in class AbstractFormControllercom.interface21.web.servlet.mvc.AbstractFormControllerrequest - current HTTP requestcommand - form object with request parameters bound onto iterrors - binder containing current errors, if anyjavax.servlet.ServletException - in case of invalid state or argumentsModelAndView
protected java.util.Map referenceData(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
Errors errors,
int page)
throws javax.servlet.ServletException
Default implementation returns null. Subclasses can override this to set reference data used in the view.
request - current HTTP requestcommand - form object with request parameters bound onto iterrors - binder containing current errors, if anypage - current wizard pagejavax.servlet.ServletException - in case of invalid state or argumentsModelAndView
protected final ModelAndView showForm(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
BindException errors)
throws javax.servlet.ServletException
showForm in class AbstractFormControllercom.interface21.web.servlet.mvc.AbstractFormControllerrequest - current HTTP requestresponse - current HTTP responseerrors - binder containing errorsjavax.servlet.ServletException - in case of invalid state or argumentsAbstractFormController.showForm(HttpServletRequest, BindException, String),
SimpleFormController.setFormView(java.lang.String)
protected final ModelAndView showPage(javax.servlet.http.HttpServletRequest request,
BindException errors,
int page)
throws javax.servlet.ServletException
request - current HTTP requesterrors - binder containing errorspage - number of page to showjavax.servlet.ServletException - in case of invalid state or argumentsprotected int getInitialPage(javax.servlet.http.HttpServletRequest request)
request - current HTTP requestprotected final java.lang.String getPageSessionAttributeName()
protected final int getCurrentPage(javax.servlet.http.HttpServletRequest request)
throws java.lang.IllegalStateException
java.lang.IllegalStateException - if the page attribute isn't in the session
anymore, i.e. when called after processSubmit.
protected final ModelAndView processSubmit(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object command,
BindException errors)
throws javax.servlet.ServletException,
java.io.IOException
processSubmit in class AbstractFormControllercom.interface21.web.servlet.mvc.AbstractFormControllerrequest - current servlet requestresponse - current servlet responsecommand - form object with request parameters bound onto iterrors - binder without errors (subclass can add errors if it wants to)javax.servlet.ServletException - in case of invalid state or argumentsjava.io.IOException - in case of I/O errorsAbstractFormController.showForm(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, com.interface21.validation.BindException)
protected abstract void validatePage(java.lang.Object command,
Errors errors,
int page)
command - form object with the current wizard stateerrors - binder containing errorspage - number of page to show
protected abstract ModelAndView processFinish(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object command,
BindException errors)
throws javax.servlet.ServletException,
java.io.IOException
request - current HTTP requestresponse - current HTTP responsecommand - form object with the current wizard stateerrors - binder containing errorsjavax.servlet.ServletException - in case of invalid state or arguments
protected abstract ModelAndView processCancel(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object command,
BindException errors)
throws javax.servlet.ServletException,
java.io.IOException
request - current HTTP requestresponse - current HTTP responsecommand - form object with the current wizard stateerrors - binder containing errorsjavax.servlet.ServletException - in case of invalid state or arguments
|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||