|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.support.WebContentGenerator
org.springframework.web.servlet.mvc.AbstractController
org.springframework.web.servlet.mvc.BaseCommandController
org.springframework.web.servlet.mvc.AbstractFormController
org.springframework.web.servlet.mvc.SimpleFormController
net.sf.springlayout.web.controller.AbstractBaseFormController
public abstract class AbstractBaseFormController
Base form controller class for all controllers. Provides delegation to a method in the controller based on the value of the "method" field / parameter in the request.
Overrides the referenceData()
method and delegates to
setupReadModeReferenceData()
if the request is considered to
be in read mode or setupEditModeReferenceData()
if the request
is in edit mode.
Also provides helper methods for getting localised messages and saving messages to the session. Messages saved to the session should be used in conjunction with an appropriate cleanup strategy such as the UserResolvingInterceptor.
MessagesInterceptor
Field Summary | |
---|---|
protected static org.apache.commons.logging.Log |
log
|
protected static java.lang.String |
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 | |
---|---|
AbstractBaseFormController()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
protected org.springframework.web.bind.ServletRequestDataBinder |
createBinder(javax.servlet.http.HttpServletRequest request,
java.lang.Object command)
Overridden to allow registering of default property editor with default to allow null. |
java.util.Map |
defineReadOnlyFields(javax.servlet.http.HttpServletRequest request)
Override to define a map of field paths that are to be treated as readOnly when the page is in edit mode. |
protected void |
editCommandBeforeBind(javax.servlet.http.HttpServletRequest request,
java.lang.Object command)
A method which allow modify the command object before do the binding. |
java.lang.Object |
getCommandObject(javax.servlet.http.HttpServletRequest request)
Allows external multi-panel validators to get the command associated with this controller. |
java.lang.String |
getDefaultEditMode()
Gets the default edit mode |
protected int[] |
getGridRemoveIndexes(javax.servlet.http.HttpServletRequest request,
java.lang.String gridId)
A convenience method to provide an Array of indexes which the User has requested to be removed from the collection contained in the DataGrid identified by the gridId provided. |
protected java.lang.String |
getMessage(java.lang.String code,
javax.servlet.http.HttpServletRequest request)
Gets a message from the resource bundle based on the current locale and key passed. |
protected java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
javax.servlet.http.HttpServletRequest request)
Gets a message from the resource bundle based on the current locale and key / arguments passed. |
protected int |
getNewGridSize(javax.servlet.http.HttpServletRequest request,
java.lang.String gridId)
A convenience method to return the size of the list for the DataGrid identified by the gridId provided. |
PageAccessResolver |
getPageAccessResolver()
Getes the pageAccessResolver for this request |
java.lang.String |
getRedirectFormView()
|
protected java.util.Map |
getStateMap(javax.servlet.http.HttpServletRequest request)
Retrieves the request parameter map in it's current updated state. |
protected java.util.Map |
getStateMapForUrl(javax.servlet.http.HttpServletRequest request)
Gets the state map with parameters only to be included in the url. |
protected org.springframework.web.servlet.ModelAndView |
handleRequestInternal(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Adds a PageAccessHolder to the request using the
WebConstants.PAGE_ACCESS_HOLDER attribute with default
settings based on the WebConstants.EDIT_MODE_PARAM passed
with the request. |
void |
initBinder(javax.servlet.http.HttpServletRequest request,
org.springframework.web.bind.ServletRequestDataBinder binder)
|
boolean |
isCommandDirty(javax.servlet.http.HttpServletRequest request)
|
protected boolean |
isDefaultPropertyEditorsAllowEmpty()
Has this controller been set to allow nulls in property editors. |
protected boolean |
isPersistValidateModeThroughGetRedirect(javax.servlet.http.HttpServletRequest request)
Checks if the validatemode has been set to survive a redirect triggered by a get. |
protected void |
manageDataGrid(javax.servlet.http.HttpServletRequest request)
Manages datagrid. |
protected void |
onBind(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
org.springframework.validation.BindException errors)
Calls the method specified in the "method" parameter of the request if one is available with a signature of: onBindAfterPreValidationMethod . |
protected void |
onBindAfterPreValidationMethod(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
org.springframework.validation.BindException errors)
Should be implemented by subclasses that wish to perform an action before validation takes place. |
protected void |
onBindAndValidate(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
org.springframework.validation.BindException errors)
Calls through to the Form validate method.. |
protected org.springframework.web.servlet.ModelAndView |
onSubmit(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object command,
org.springframework.validation.BindException errors)
Calls the method specified in the "method" parameter of the request. |
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)
|
protected java.util.Map |
referenceData(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
org.springframework.validation.Errors errors)
Default implementation here first checks to see the mode and defers to setupReadModeReferenceData or
setupEditModeReferenceData depending on the current mode. |
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 |
registerDefaultPropertyEditors(javax.servlet.http.HttpServletRequest request,
org.springframework.web.bind.ServletRequestDataBinder binder)
register default property editors with allow empty |
protected void |
saveMessages(Messages messages,
javax.servlet.http.HttpServletRequest request)
Save the messages to the session |
void |
setCommandClean(javax.servlet.http.HttpServletRequest request)
|
void |
setCommandDirty(javax.servlet.http.HttpServletRequest request)
|
void |
setDefaultEditMode(java.lang.String defaultEditMode)
Sets the default edit mode - "1" or "true" for editMode, "0" or "false" for read mode. |
void |
setDefaultPropertyEditorsAllowEmpty(boolean defaultPropertyEditorsAllowEmpty)
Set the controller to override the default Spring behaviour of registering property editors with allow empty as false to allowEmpty=true If this property is set to true, all default property editors are registered to allow null values. |
protected void |
setEditMode(javax.servlet.http.HttpServletRequest request,
boolean editMode)
Sets the edit mode for the current request. |
void |
setForm(Form form)
The form for this controller |
void |
setPageAccessResolver(PageAccessResolver pageAccessResolver)
Sets the pageAccessResolver for the controller |
protected void |
setPersistValidateModeThroughGetRedirect(javax.servlet.http.HttpServletRequest request)
Sets whether the current validation mode state should survive a redirect caused by a get. |
void |
setRedirectFormView(java.lang.String redirectView)
|
protected void |
setStateMapField(javax.servlet.http.HttpServletRequest request,
java.lang.String name,
java.lang.String value)
Sets the parameter name/value pair in the current state map. |
protected java.util.Map |
setupEditModeReferenceData(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
org.springframework.validation.Errors errors)
Create a reference data map in EDIT MODE for the given request and command, consisting of bean name/bean instance pairs as expected by ModelAndView. |
protected java.util.Map |
setupReadModeReferenceData(javax.servlet.http.HttpServletRequest request,
java.lang.Object command,
org.springframework.validation.Errors errors)
Create a reference data map in READ MODE for the given request and command, consisting of bean name/bean instance pairs as expected by ModelAndView. |
protected org.springframework.web.servlet.ModelAndView |
showForm(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.springframework.validation.BindException errors)
Calls the controller pageAccessResolver if it exists and then super.showForm |
Methods inherited from class org.springframework.web.servlet.mvc.SimpleFormController |
---|
doSubmitAction, getFormView, getSuccessView, isFormChangeRequest, onFormChange, onFormChange, onSubmit, onSubmit, referenceData, setFormView, setSuccessView, showForm, suppressValidation |
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 |
---|
protected static org.apache.commons.logging.Log log
protected static java.lang.String PERSIST_VAL_THROUGH_REDIRECT
Constructor Detail |
---|
public AbstractBaseFormController()
Method Detail |
---|
protected boolean isDefaultPropertyEditorsAllowEmpty()
public void setPageAccessResolver(PageAccessResolver pageAccessResolver)
pageAccessResolver
- public PageAccessResolver getPageAccessResolver()
public void setDefaultPropertyEditorsAllowEmpty(boolean defaultPropertyEditorsAllowEmpty)
defaultPropertyEditorsAllowEmpty
- public void setForm(Form form)
form
- public void setDefaultEditMode(java.lang.String defaultEditMode)
defaultEditMode
- The defaultEditMode to set.public void initBinder(javax.servlet.http.HttpServletRequest request, org.springframework.web.bind.ServletRequestDataBinder binder) throws java.lang.Exception
initBinder
in interface FormController
initBinder
in class org.springframework.web.servlet.mvc.BaseCommandController
java.lang.Exception
public java.lang.Object getCommandObject(javax.servlet.http.HttpServletRequest request)
getCommandObject
in interface FormController
request
-
java.lang.Exception
public java.lang.String getDefaultEditMode()
protected final void onBind(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.BindException errors) throws java.lang.Exception
onBindAfterPreValidationMethod
. Please note that any code
which would have been placed in the onBind
method under the
normal Spring framework must now be placed in
onBindAfterPreValidationMethod
.
onBind
in class org.springframework.web.servlet.mvc.BaseCommandController
java.lang.Exception
protected void onBindAfterPreValidationMethod(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.BindException errors) throws java.lang.Exception
request
- command
-
java.lang.Exception
BaseCommandController.onBind(javax.servlet.http.HttpServletRequest,
java.lang.Object)
protected org.springframework.web.servlet.ModelAndView onSubmit(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object command, org.springframework.validation.BindException errors) throws java.lang.Exception
save()
, delete()
, approve()
,
reject()
.
onSubmit
in class org.springframework.web.servlet.mvc.SimpleFormController
java.lang.Exception
SimpleFormController.onSubmit(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse, java.lang.Object,
org.springframework.validation.BindException)
protected void onBindAndValidate(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.BindException errors) throws java.lang.Exception
Form
validate method.. Subclasses that
override this method should call super if
requestAwareValidator
or PanelFormGroup
validation is to be automatically invoked.
onBindAndValidate
in class org.springframework.web.servlet.mvc.BaseCommandController
java.lang.Exception
BaseCommandController.onBindAndValidate(javax.servlet.http.HttpServletRequest,
java.lang.Object, org.springframework.validation.BindException)
protected java.util.Map referenceData(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.Errors errors) throws java.lang.Exception
setupReadModeReferenceData
or
setupEditModeReferenceData
depending on the current mode.
Override either of these methods to get referencedata setup at the
appropriate time. If more control is required, override this method
directly and defer to setupReadModeReferenceData
or
setupEditModeReferenceData
when appropriate.
referenceData
in class org.springframework.web.servlet.mvc.SimpleFormController
java.lang.Exception
SimpleFormController.referenceData(javax.servlet.http.HttpServletRequest,
java.lang.Object, org.springframework.validation.Errors)
protected java.util.Map setupEditModeReferenceData(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.Errors errors) throws java.lang.Exception
Create a reference data map in EDIT MODE for the given request and command, consisting of bean name/bean instance pairs as expected by ModelAndView.
Subclasses can override this to setup reference data used in the view. Override this method instead of the standard referenceData() method to get conditional execution based on the page read / edit state for free.
NOTE: This method will be called in EDIT mode only
request
- current HTTP requestcommand
- form object with request parameters bound onto iterrors
- validation errors holder
null
if none
java.lang.Exception
- in case of invalid state or argumentsSimpleFormController.referenceData(javax.servlet.http.HttpServletRequest,
java.lang.Object, org.springframework.validation.Errors)
protected java.util.Map setupReadModeReferenceData(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.Errors errors) throws java.lang.Exception
Create a reference data map in READ MODE for the given request and command, consisting of bean name/bean instance pairs as expected by ModelAndView.
Subclasses can override this to setup reference data used in the view. Override this method instead of the standard referenceData() method to get conditional execution based on the page read / edit state for free.
NOTE: This method will be called in READ mode only
request
- current HTTP requestcommand
- form object with request parameters bound onto iterrors
- validation errors holder
null
if none
java.lang.Exception
- in case of invalid state or argumentsSimpleFormController.referenceData(javax.servlet.http.HttpServletRequest,
java.lang.Object, org.springframework.validation.Errors)
protected org.springframework.web.servlet.ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
Adds a PageAccessHolder
to the request using the
WebConstants.PAGE_ACCESS_HOLDER
attribute with default
settings based on the WebConstants.EDIT_MODE_PARAM
passed
with the request. Calls through to super to return to the regular
controller lifecycle. On GET's calls the
PageAccessResolver for the
controller if present.
Note: If the WebConstants.PAGE_ACCESS_HOLDER
attribute is
set at a lower level controller such as the AbstractListFormController,
the existing pageAccessHolder will remain untouched and the
WebConstants.EDIT_MODE_PARAM
will be ignored.
handleRequestInternal
in class org.springframework.web.servlet.mvc.AbstractFormController
java.lang.Exception
AbstractController.handleRequestInternal(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse)
protected void manageDataGrid(javax.servlet.http.HttpServletRequest request)
request
- protected void editCommandBeforeBind(javax.servlet.http.HttpServletRequest request, java.lang.Object command) throws java.lang.Exception
request
-
java.lang.Exception
protected int[] getGridRemoveIndexes(javax.servlet.http.HttpServletRequest request, java.lang.String gridId) throws org.springframework.web.bind.ServletRequestBindingException
editCommandBeforeBind()
to allow the Collection which
the DataGrid is bound to to be modified before binding occurs.
request
- gridId
- identifies the DataGrid which has 0 or more indexes to be
removed.
org.springframework.web.bind.ServletRequestBindingException
protected int getNewGridSize(javax.servlet.http.HttpServletRequest request, java.lang.String gridId)
request
- gridId
- the id of the DataGrid to check for a user request to add a row.
protected boolean isPersistValidateModeThroughGetRedirect(javax.servlet.http.HttpServletRequest request)
request
-
protected void setPersistValidateModeThroughGetRedirect(javax.servlet.http.HttpServletRequest request)
request
- protected java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, javax.servlet.http.HttpServletRequest request) throws org.springframework.context.NoSuchMessageException
code
- the key to the messageargs
- arguments to be parsed with the messagerequest
- current request
org.springframework.context.NoSuchMessageException
protected java.lang.String getMessage(java.lang.String code, javax.servlet.http.HttpServletRequest request) throws org.springframework.context.NoSuchMessageException
code
- the key to the messagerequest
- current request
org.springframework.context.NoSuchMessageException
protected void saveMessages(Messages messages, javax.servlet.http.HttpServletRequest request)
messages
- request
- protected void setEditMode(javax.servlet.http.HttpServletRequest request, boolean editMode)
request
- editMode
- to set the current request to: true - editMode, false -
readmode.public java.util.Map defineReadOnlyFields(javax.servlet.http.HttpServletRequest request)
request
-
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
request
- response
- command
- errors
-
java.lang.Exception
protected org.springframework.web.bind.ServletRequestDataBinder createBinder(javax.servlet.http.HttpServletRequest request, java.lang.Object command) throws java.lang.Exception
createBinder
in class org.springframework.web.servlet.mvc.BaseCommandController
request
- current HTTP requestcommand
- the command to bind onto
java.lang.Exception
- in case of invalid state or argumentsBaseCommandController.bindAndValidate(javax.servlet.http.HttpServletRequest, java.lang.Object)
,
initBinder(javax.servlet.http.HttpServletRequest, org.springframework.web.bind.ServletRequestDataBinder)
,
BaseCommandController.setMessageCodesResolver(org.springframework.validation.MessageCodesResolver)
,
BaseCommandController.setBindingErrorProcessor(org.springframework.validation.BindingErrorProcessor)
protected void registerDefaultPropertyEditors(javax.servlet.http.HttpServletRequest request, org.springframework.web.bind.ServletRequestDataBinder binder)
request
- binder
- protected java.util.Map getStateMap(javax.servlet.http.HttpServletRequest request)
request
-
protected void setStateMapField(javax.servlet.http.HttpServletRequest request, java.lang.String name, java.lang.String value)
request
- name
- value
- public boolean isCommandDirty(javax.servlet.http.HttpServletRequest request)
public void setCommandDirty(javax.servlet.http.HttpServletRequest request)
public void setCommandClean(javax.servlet.http.HttpServletRequest request)
protected java.util.Map getStateMapForUrl(javax.servlet.http.HttpServletRequest request)
request
-
public void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception
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
processFormSubmission
in class org.springframework.web.servlet.mvc.SimpleFormController
java.lang.Exception
public void setRedirectFormView(java.lang.String redirectView)
public java.lang.String getRedirectFormView()
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
showForm
in class org.springframework.web.servlet.mvc.SimpleFormController
java.lang.Exception
SimpleFormController.showForm(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse,
org.springframework.validation.BindException)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |