|
[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.SimpleFormController
Concrete FormController implementation that provides configurable form and success views, and an onSubmit chain for convenient overriding.
Automatically resubmits to the form view in case of validation errors, and renders the success view in case of a valid submission.
The submit behavior can be customized by overriding one of the onSubmit methods. Submit actions can be used as custom validation if necessary (e.g. login), by calling showForm in case of validation errors.
| 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 | |
SimpleFormController()
Create a new SimpleFormController. |
|
| Method Summary | |
protected java.lang.String |
getFormView()
Return the name of the view that should be used for form display. |
protected java.lang.String |
getSuccessView()
Return the name of the view that should be shown on successful submit. |
protected ModelAndView |
onSubmit(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object command,
BindException errors)
Submit callback with all parameters. |
protected ModelAndView |
onSubmit(java.lang.Object command)
Simplest onSubmit version. |
protected ModelAndView |
processSubmit(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object command,
BindException errors)
This implementation calls showForm in case of errors, and delegates to onSubmit's full version else. |
protected java.util.Map |
referenceData(javax.servlet.http.HttpServletRequest request)
Create a reference data map for the given request. |
protected java.util.Map |
referenceData(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
Errors errors)
Create a reference data map for the given request, command, and errors, consisting of bean name/bean instance pairs as expected by ModelAndView. |
void |
setFormView(java.lang.String formView)
Set the name of the view that should be used for form display. |
void |
setSuccessView(java.lang.String successView)
Set the name of the view that should be shown on successful submit. |
protected ModelAndView |
showForm(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
BindException errors)
This implementation shows the configured form view. |
| 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, onBindAndValidate, 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 |
| Constructor Detail |
public SimpleFormController()
Subclasses should set the following properties, either in the constructor or via a BeanFactory: commandClass, beanName, sessionForm, formView, successView. Note that commandClass doesn't need to be set when overriding formBackingObject, as this determines the class anyway.
BaseCommandController.setCommandClass(java.lang.Class),
BaseCommandController.setBeanName(java.lang.String),
AbstractFormController.setSessionForm(boolean),
setFormView(java.lang.String),
setSuccessView(java.lang.String)| Method Detail |
public final void setFormView(java.lang.String formView)
protected final java.lang.String getFormView()
public final void setSuccessView(java.lang.String successView)
protected final java.lang.String getSuccessView()
protected java.util.Map referenceData(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
Errors errors)
throws javax.servlet.ServletException
Default implementation delegates to referenceData(request). Subclasses can override this to set reference data used in the view.
referenceData in class 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)
throws javax.servlet.ServletException
Default implementation returns null. Subclasses can override this to set reference data used in the view.
request - current HTTP requestjavax.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 AbstractFormControllersetFormView(java.lang.String)
protected 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
This should only be overridden to check for an action that should be executed without respect to binding errors, like a cancel action.
processSubmit in class AbstractFormControllershowForm(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, com.interface21.validation.BindException),
onSubmit(HttpServletRequest,HttpServletResponse,Object,BindException)
protected ModelAndView onSubmit(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object command,
BindException errors)
throws javax.servlet.ServletException,
java.io.IOException
Default implementation delegates to onSubmit(command,errors). Subclasses can override this to provide custom submission handling like triggering a custom action. They can also provide custom validation and call showForm/super.onSubmit accordingly.
request - 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 errorsonSubmit(Object),
showForm(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, com.interface21.validation.BindException)
protected ModelAndView onSubmit(java.lang.Object command)
throws javax.servlet.ServletException
Default implementation prepares success view.
command - form object with request parameters bound onto itjavax.servlet.ServletException - in case of invalid state or argumentssetSuccessView(java.lang.String)
|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||