net.sf.springlayout.web.controller
Class AbstractPanelFormController

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.support.WebContentGenerator
              extended by org.springframework.web.servlet.mvc.AbstractController
                  extended by org.springframework.web.servlet.mvc.BaseCommandController
                      extended by org.springframework.web.servlet.mvc.AbstractFormController
                          extended by org.springframework.web.servlet.mvc.SimpleFormController
                              extended by net.sf.springlayout.web.controller.AbstractBaseFormController
                                  extended by net.sf.springlayout.web.controller.AbstractPanelFormController
All Implemented Interfaces:
FormController, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.web.servlet.mvc.Controller

public abstract class AbstractPanelFormController
extends AbstractBaseFormController
implements org.springframework.beans.factory.InitializingBean

Abstract base class for providing common methods to controllers grouped in a multipage / multi-controller configuration. Should be used as an alternative to the WizardFormController when a different controller is required for each page and Spring Layout validation and tags are to be used.

Author:
Rob Monie

Field Summary
protected static org.apache.commons.logging.Log log
           
 
Fields inherited from class net.sf.springlayout.web.controller.AbstractBaseFormController
PERSIST_VAL_THROUGH_REDIRECT
 
Fields inherited from class org.springframework.web.servlet.mvc.BaseCommandController
DEFAULT_COMMAND_NAME
 
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator
HEADER_CACHE_CONTROL, HEADER_EXPIRES, HEADER_PRAGMA, METHOD_GET, METHOD_HEAD, METHOD_POST
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
AbstractPanelFormController()
           
 
Method Summary
 void addToStateMap(javax.servlet.http.HttpServletRequest request, java.lang.Object key, java.lang.Object value)
          Simple method to quickly add a parameter to the state map.
 void afterPropertiesSet()
           
 org.springframework.web.servlet.ModelAndView changePanel(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object command, org.springframework.validation.BindException errors)
          Used to change panels on a multi-panel controller after binding the current form data to the command object.
 PanelFormGroup getPanelFormGroup()
          gets the panel form group
 java.lang.String getRedirectFormView()
           
protected  org.springframework.web.servlet.ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Adds the commandName to the request using the WebConstants.COMMAND_NAME attribute which is required by the layout:panel tag then calls super to return to normal controller lifecycle.
 void initBinder(javax.servlet.http.HttpServletRequest request, org.springframework.web.bind.ServletRequestDataBinder binder)
          Overridden to increase the visibility.
 boolean isCurrentlyValidating(javax.servlet.http.HttpServletRequest request)
          returns whether currently validating.
protected  boolean isValidateMode(javax.servlet.http.HttpServletRequest request)
           
protected  void onBindAndValidate(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.BindException errors)
          Calls through to the PanelFormGroup validate method if supplied before passing onto super...
protected  org.springframework.web.servlet.ModelAndView processFormSubmission(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object command, org.springframework.validation.BindException errors)
           
 org.springframework.web.servlet.ModelAndView refresh(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object command, org.springframework.validation.BindException errors)
          Refreshes the current page after binding fields to the model.
protected  void setCurrentlyValidating(javax.servlet.http.HttpServletRequest request, boolean validating)
          Sets a request attribute as to whether we're currently validating.
 void setForm(Form form)
          Overrides the setting of forms and throws an error if set.
 void setPanelFormGroup(PanelFormGroup panelFormGroup)
          Sets the panelFormGroup for this controller
 void setRedirectFormView(java.lang.String redirectFormView)
           
protected  void setValidateMode(javax.servlet.http.HttpServletRequest request, boolean validateMode)
           
protected  org.springframework.web.servlet.ModelAndView showForm(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.validation.BindException errors)
          Checks the session for errors and if present and in validation mode adds them to the current errors object and removes them from the session.
protected  boolean suppressValidation(javax.servlet.http.HttpServletRequest request)
          Supresseses validation of requests if not in validate mode.
 
Methods inherited from class net.sf.springlayout.web.controller.AbstractBaseFormController
createBinder, defineReadOnlyFields, editCommandBeforeBind, getCommandObject, getDefaultEditMode, getGridRemoveIndexes, getMessage, getMessage, getNewGridSize, getPageAccessResolver, getStateMap, getStateMapForUrl, isCommandDirty, isDefaultPropertyEditorsAllowEmpty, isPersistValidateModeThroughGetRedirect, manageDataGrid, onBind, onBindAfterPreValidationMethod, onSubmit, referenceData, registerDefaultPropertyEditors, saveMessages, setCommandClean, setCommandDirty, setDefaultEditMode, setDefaultPropertyEditorsAllowEmpty, setEditMode, setPageAccessResolver, setPersistValidateModeThroughGetRedirect, setStateMapField, setupEditModeReferenceData, setupReadModeReferenceData
 
Methods inherited from class org.springframework.web.servlet.mvc.SimpleFormController
doSubmitAction, getFormView, getSuccessView, isFormChangeRequest, onFormChange, onFormChange, onSubmit, onSubmit, referenceData, setFormView, setSuccessView, showForm
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractFormController
currentFormObject, formBackingObject, getCommand, getErrorsForNewForm, getFormSessionAttributeName, getFormSessionAttributeName, handleInvalidSubmit, isBindOnNewForm, isFormSubmission, isSessionForm, onBindOnNewForm, onBindOnNewForm, setBindOnNewForm, setSessionForm, showForm, showForm, showNewForm
 
Methods inherited from class org.springframework.web.servlet.mvc.BaseCommandController
bindAndValidate, checkCommand, createCommand, getBindingErrorProcessor, getCommandClass, getCommandName, getMessageCodesResolver, getPropertyEditorRegistrars, getValidator, getValidators, initApplicationContext, isValidateOnBinding, onBind, setBindingErrorProcessor, setCommandClass, setCommandName, setMessageCodesResolver, setPropertyEditorRegistrar, setPropertyEditorRegistrars, setValidateOnBinding, setValidator, setValidators, suppressBinding
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractController
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession
 
Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, getCacheSeconds, getSupportedMethods, isRequireSession, isUseCacheControlHeader, isUseExpiresHeader, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseExpiresHeader
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, isContextRequired
 
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
 
Methods inherited from interface net.sf.springlayout.web.controller.FormController
getCommandName
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Constructor Detail

AbstractPanelFormController

public AbstractPanelFormController()
Method Detail

setPanelFormGroup

public void setPanelFormGroup(PanelFormGroup panelFormGroup)
Sets the panelFormGroup for this controller

Parameters:
panelFormGroup -

getPanelFormGroup

public PanelFormGroup getPanelFormGroup()
gets the panel form group

Returns:

setForm

public void setForm(Form form)
Overrides the setting of forms and throws an error if set. Only a panelFormGroup should be set within this controller context

Overrides:
setForm in class AbstractBaseFormController
Parameters:
form -

changePanel

public org.springframework.web.servlet.ModelAndView changePanel(javax.servlet.http.HttpServletRequest request,
                                                                javax.servlet.http.HttpServletResponse response,
                                                                java.lang.Object command,
                                                                org.springframework.validation.BindException errors)
                                                         throws java.lang.Exception
Used to change panels on a multi-panel controller after binding the current form data to the command object.

Parameters:
request -
response -
command -
errors -
Returns:
Throws:
java.lang.Exception

suppressValidation

protected boolean suppressValidation(javax.servlet.http.HttpServletRequest request)
Supresseses validation of requests if not in validate mode.

Overrides:
suppressValidation in class org.springframework.web.servlet.mvc.SimpleFormController
Parameters:
request - the current request
See Also:
SimpleFormController.suppressValidation(javax.servlet.http.HttpServletRequest)

showForm

protected org.springframework.web.servlet.ModelAndView showForm(javax.servlet.http.HttpServletRequest request,
                                                                javax.servlet.http.HttpServletResponse response,
                                                                org.springframework.validation.BindException errors)
                                                         throws java.lang.Exception
Checks the session for errors and if present and in validation mode adds them to the current errors object and removes them from the session. This allows errors to persist when moving between tabs in edit mode.

Overrides:
showForm in class AbstractBaseFormController
Throws:
java.lang.Exception
See Also:
SimpleFormController.showForm(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.springframework.validation.BindException)

handleRequestInternal

protected org.springframework.web.servlet.ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request,
                                                                             javax.servlet.http.HttpServletResponse response)
                                                                      throws java.lang.Exception
Adds the commandName to the request using the WebConstants.COMMAND_NAME attribute which is required by the layout:panel tag then calls super to return to normal controller lifecycle.

Overrides:
handleRequestInternal in class AbstractBaseFormController
Throws:
java.lang.Exception
See Also:
AbstractController.handleRequestInternal(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

refresh

public org.springframework.web.servlet.ModelAndView refresh(javax.servlet.http.HttpServletRequest request,
                                                            javax.servlet.http.HttpServletResponse response,
                                                            java.lang.Object command,
                                                            org.springframework.validation.BindException errors)
                                                     throws java.lang.Exception
Refreshes the current page after binding fields to the model. Useful for generic refreshing of the UI after front end changes

Overrides:
refresh in class AbstractBaseFormController
Parameters:
request -
response -
command -
errors -
Returns:
Throws:
java.lang.Exception

onBindAndValidate

protected void onBindAndValidate(javax.servlet.http.HttpServletRequest request,
                                 java.lang.Object command,
                                 org.springframework.validation.BindException errors)
                          throws java.lang.Exception
Calls through to the PanelFormGroup validate method if supplied before passing onto super...

Overrides:
onBindAndValidate in class AbstractBaseFormController
Throws:
java.lang.Exception
See Also:
BaseCommandController.onBindAndValidate(javax.servlet.http.HttpServletRequest, java.lang.Object, org.springframework.validation.BindException)

setRedirectFormView

public void setRedirectFormView(java.lang.String redirectFormView)
Overrides:
setRedirectFormView in class AbstractBaseFormController

getRedirectFormView

public java.lang.String getRedirectFormView()
Overrides:
getRedirectFormView in class AbstractBaseFormController

processFormSubmission

protected org.springframework.web.servlet.ModelAndView processFormSubmission(javax.servlet.http.HttpServletRequest request,
                                                                             javax.servlet.http.HttpServletResponse response,
                                                                             java.lang.Object command,
                                                                             org.springframework.validation.BindException errors)
                                                                      throws java.lang.Exception
Overrides:
processFormSubmission in class AbstractBaseFormController
Throws:
java.lang.Exception

isValidateMode

protected boolean isValidateMode(javax.servlet.http.HttpServletRequest request)

setValidateMode

protected void setValidateMode(javax.servlet.http.HttpServletRequest request,
                               boolean validateMode)

setCurrentlyValidating

protected void setCurrentlyValidating(javax.servlet.http.HttpServletRequest request,
                                      boolean validating)
Sets a request attribute as to whether we're currently validating. This is different to the validateMode param and the two should not be confused.

Parameters:
request -
validating -

isCurrentlyValidating

public boolean isCurrentlyValidating(javax.servlet.http.HttpServletRequest request)
returns whether currently validating. Not to be confused with the ValidateMode param.

Parameters:
request -
Returns:

addToStateMap

public void addToStateMap(javax.servlet.http.HttpServletRequest request,
                          java.lang.Object key,
                          java.lang.Object value)
Simple method to quickly add a parameter to the state map. Anything put in the statemap will be reflected in the url throughout navigation of a multi- panel form

Parameters:
request -
key -
value -

initBinder

public void initBinder(javax.servlet.http.HttpServletRequest request,
                       org.springframework.web.bind.ServletRequestDataBinder binder)
                throws java.lang.Exception
Overridden to increase the visibility. Calls super.initBinder(request, binder)

Specified by:
initBinder in interface FormController
Overrides:
initBinder in class AbstractBaseFormController
Throws:
java.lang.Exception
See Also:
BaseCommandController.initBinder(javax.servlet.http.HttpServletRequest, org.springframework.web.bind.ServletRequestDataBinder)

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Overrides:
afterPropertiesSet in class AbstractBaseFormController
Throws:
java.lang.Exception


Copyright © 2005-2007 Spring Layout Team. All Rights Reserved.