nl.gx.webmanager.springmvc.controller
Class BaseWebmanagerController

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 nl.gx.webmanager.springmvc.controller.BaseWebmanagerController
All Implemented Interfaces:
org.springframework.context.ApplicationContextAware, org.springframework.web.context.ServletContextAware, org.springframework.web.servlet.mvc.Controller
Direct Known Subclasses:
ComponentController

public abstract class BaseWebmanagerController
extends org.springframework.web.servlet.mvc.SimpleFormController

This class is the base class for all WebManager Spring controllers. It contains controller logic for controllers running inside the Spring application context as well as controllers to which controller callback methods are delegated by these application context controllers, used in case of component composition. This class is typically extended by custom controllers contained by WCBs but also by the main controllers of each component (like the PanelController, MediaItemVersionController and PageVersionController), running inside the Spring application context.

Since:
WebManager 9.0.8
Author:
ivol

Field Summary
protected  java.lang.Object formBackingObject
           
static java.lang.String PROTOCOL_PROCESSED_KEY
          Key for the request attribute that indicates if the old fashioned siteworks protocol has been invoked.
 
Fields inherited from class org.springframework.web.servlet.mvc.BaseCommandController
DEFAULT_COMMAND_NAME
 
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator
METHOD_GET, METHOD_HEAD, METHOD_POST
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
BaseWebmanagerController()
           
 
Method Summary
protected  void addControllerDelegation(DelegatedController controller, FormBackingObject formBackingObject, javax.servlet.http.HttpServletRequest request)
          Adds a sub controller and corresponding form backing object to the local controller delegation map.
 void addDisallowedField(org.springframework.web.bind.ServletRequestDataBinder binder, java.lang.String field)
          Adds ad disallowed field to the list of allowed fields contained by the binder
 void addEditView(WmEditView editView)
          Adds an edit view to this controller and removes any edit view that already exists and has the same value.
 void addEditViews(WmEditView[] editViews)
          Adds an array of edit views to this controller and removes any edit view that already exists and has the same value.
 void addResourceBaseName(java.lang.String resourceBaseName)
          Adds a single resource base name to the list of resource base names for this controller.
 void addValidator(org.springframework.validation.Validator validator)
          Helper method to add a validator the the list of validators
protected abstract  void createEditViews()
          Callback to add edit views.
protected abstract  void createResourceBaseNames(java.lang.Object command)
          Callback to add resource base names.
 java.lang.Object formBackingObject(javax.servlet.http.HttpServletRequest request)
          Retrieve a form backing object for the current form from the given request.
 java.util.LinkedHashMap<DelegatedController,FormBackingObject> getControllerDelegationMap()
          Return the sub controller and corresponding form backing objects stored on the local controller delegation map.
 EditContext getEditContext()
           
protected  java.lang.String getEditLanguageLabel(java.lang.String label)
          Deprecated. It should not be necessary to retrieve a language specific text within the scope of a controller.
 EditView getEditView()
          get the default editview; the edit view with empty value
 EditView getEditViewByValue(java.lang.String value)
          Get the editview with the given value.
protected  java.util.ArrayList<WmEditView> getEditViews()
          Return the array list with all edit views on the current stack
 PresentationContext getPresentationContext()
           
 java.util.ArrayList<java.lang.String> getResourceBaseNames()
          Return the resource base names for this controller
 javax.servlet.ServletContext getServletContextHack()
           
protected  java.lang.Integer getVersion(javax.servlet.http.HttpServletRequest request)
          Returns the value of the id parameter in the request as the id of the current version.
static Website getWebsite(nl.gx.webmanager.foundation.Session wmSession)
           
 Website getWebsiteByRequest(javax.servlet.http.HttpServletRequest request)
          Get the website according to the webid in the qs.
 nl.gx.webmanager.foundation.Session getWmSession(javax.servlet.http.HttpServletRequest request)
          Returns the webmanager session that the controller uses for handling the request.
 void initBinder(javax.servlet.http.HttpServletRequest request, org.springframework.web.bind.ServletRequestDataBinder binder)
          Initialize the given binder with custom editors for the Date class.
 void initialize(javax.servlet.http.HttpServletRequest request)
          Initialize the controller
 boolean isReloadWebManager(javax.servlet.http.HttpServletRequest request)
          Returns true if WebManager should be reloaded after completing the request.
 void onBind(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.BindException errors)
          This is method is called by the Spring framework just after binding posted form values onto the form backing object.
 void onBindAndValidate(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.BindException errors)
          This is method is called by the Spring framework just after binding posted form values onto the form backing object and calling the onBind.
 void onSubmit(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object command, org.springframework.validation.BindException errors, org.springframework.web.servlet.ModelAndView modelAndView)
          Methods that override this method MUST call super.onSubmit in order to function properly.
protected  void popNestedPath(org.springframework.validation.BindException errors, FormBackingObject formBackingObject)
          Pops a nested path from the stack for spring binding.
protected  void pushNestedPath(org.springframework.validation.BindException errors, FormBackingObject formBackingObject)
          Pushes the nested path onto the stack for spring binding.
 java.util.Map<java.lang.String,java.lang.Object> referenceData(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.Errors errors)
          Methods that override this method MUST call super.referenceData in order to function properly.
protected  void removeControllerDelegation(DelegatedController controller)
          Removes a sub controller and corresponding form backing object to the local controller delegation map.
 void setReloadWebManager(boolean reloadWebManager, javax.servlet.http.HttpServletRequest request)
          Set if WebManager should be reloaded after completing the request.
 org.springframework.web.servlet.ModelAndView showForm(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.validation.BindException errors)
          Default implementation of showForm.
 
Methods inherited from class org.springframework.web.servlet.mvc.SimpleFormController
doSubmitAction, getFormView, getSuccessView, isFormChangeRequest, isFormChangeRequest, onFormChange, onFormChange, onSubmit, onSubmit, onSubmit, processFormSubmission, referenceData, setFormView, setSuccessView, showForm, suppressValidation
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractFormController
currentFormObject, getCommand, getErrorsForNewForm, getFormSessionAttributeName, getFormSessionAttributeName, handleInvalidSubmit, handleRequestInternal, isBindOnNewForm, isFormSubmission, isSessionForm, onBindOnNewForm, onBindOnNewForm, setBindOnNewForm, setSessionForm, showForm, showForm, showNewForm
 
Methods inherited from class org.springframework.web.servlet.mvc.BaseCommandController
bindAndValidate, checkCommand, createBinder, createCommand, getBindingErrorProcessor, getCommandClass, getCommandName, getMessageCodesResolver, getPropertyEditorRegistrars, getValidator, getValidators, getWebBindingInitializer, initApplicationContext, isValidateOnBinding, onBind, prepareBinder, setBindingErrorProcessor, setCommandClass, setCommandName, setMessageCodesResolver, setPropertyEditorRegistrar, setPropertyEditorRegistrars, setValidateOnBinding, setValidator, setValidators, setWebBindingInitializer, suppressBinding, suppressValidation, suppressValidation, useDirectFieldAccess
 
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, isUseCacheControlNoStore, isUseExpiresHeader, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseCacheControlNoStore, setUseExpiresHeader
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
 
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

PROTOCOL_PROCESSED_KEY

public static final java.lang.String PROTOCOL_PROCESSED_KEY
Key for the request attribute that indicates if the old fashioned siteworks protocol has been invoked.

See Also:
Constant Field Values

formBackingObject

protected java.lang.Object formBackingObject
Constructor Detail

BaseWebmanagerController

public BaseWebmanagerController()
Method Detail

initialize

public void initialize(javax.servlet.http.HttpServletRequest request)
Initialize the controller

Parameters:
request -

formBackingObject

public java.lang.Object formBackingObject(javax.servlet.http.HttpServletRequest request)
                                   throws javax.servlet.ServletException
Retrieve a form backing object for the current form from the given request. Override this method to return the form backing object

Overrides:
formBackingObject in class org.springframework.web.servlet.mvc.AbstractFormController
Parameters:
request - current HTTP request
Returns:
the FormBackingObject
Throws:
java.lang.Exception - in case of invalid state or arguments
javax.servlet.ServletException

initBinder

public void initBinder(javax.servlet.http.HttpServletRequest request,
                       org.springframework.web.bind.ServletRequestDataBinder binder)
                throws java.lang.Exception
Initialize the given binder with custom editors for the Date class.

Overrides:
initBinder in class org.springframework.web.servlet.mvc.BaseCommandController
Parameters:
request - current HTTP request
binder - new binder instance
Throws:
java.lang.Exception - in case of invalid state or arguments

onBind

public void onBind(javax.servlet.http.HttpServletRequest request,
                   java.lang.Object command,
                   org.springframework.validation.BindException errors)
            throws java.lang.Exception
This is method is called by the Spring framework just after binding posted form values onto the form backing object. The methods delegates the onBind method to sub controllers and corresponding form backing objects.

Overrides:
onBind in class org.springframework.web.servlet.mvc.BaseCommandController
Parameters:
request - current HTTP request
command - the command object to perform further binding on
errors - validation errors holder, allowing for additional custom registration of binding errors
Throws:
java.lang.Exception - in case of invalid state or arguments

onBindAndValidate

public void onBindAndValidate(javax.servlet.http.HttpServletRequest request,
                              java.lang.Object command,
                              org.springframework.validation.BindException errors)
                       throws java.lang.Exception
This is method is called by the Spring framework just after binding posted form values onto the form backing object and calling the onBind. The methods delegates the onBindAndValidate method to sub controllers and corresponding form backing objects and invokes the validators registered for this controller.

Overrides:
onBindAndValidate in class org.springframework.web.servlet.mvc.BaseCommandController
Parameters:
request - current HTTP request
command - the command object, still allowing for further binding
errors - validation errors holder, allowing for additional custom validation
Throws:
java.lang.Exception - in case of invalid state or arguments

onSubmit

public void onSubmit(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     java.lang.Object command,
                     org.springframework.validation.BindException errors,
                     org.springframework.web.servlet.ModelAndView modelAndView)
              throws java.lang.Exception
Methods that override this method MUST call super.onSubmit in order to function properly. Delegates the onSubmit to all registered sub components.

Parameters:
request - current servlet request
response - current servlet response
command - form object with request parameters bound onto it
errors - Errors instance without errors (subclass can add errors if it wants to)
modelAndView - the model and view prepared by the main spring controller
Throws:
java.lang.Exception - in case of errors

showForm

public 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
Default implementation of showForm. Delegates the showForm to all sub controllers and adds the returned ModelAndView's to the edit context. Then it creates a new wmMultiEditView from the defined edit views and a new model on which all referenceData is put.

Overrides:
showForm in class org.springframework.web.servlet.mvc.SimpleFormController
Parameters:
request - current http request
response - current http response
errors - Errors instance without errors (subclass can add errors if it wants to)
Throws:
java.lang.Exception

referenceData

public java.util.Map<java.lang.String,java.lang.Object> referenceData(javax.servlet.http.HttpServletRequest request,
                                                                      java.lang.Object command,
                                                                      org.springframework.validation.Errors errors)
                                                               throws java.lang.Exception
Methods that override this method MUST call super.referenceData in order to function properly. This method is called by the Spring framework to allow the controller to put additional data onto the model to be offered to the view. Note that this is the model returned by the controller itself, not the model contained by the main spring controller. To add properties to the main model, override the showForm method with the model as input parameter.

Overrides:
referenceData in class org.springframework.web.servlet.mvc.SimpleFormController
Parameters:
request - current HTTP request
command - the command object to perform further binding on
errors - validation errors holder, allowing for additional custom registration of binding errors
Returns:
a Map with reference data entries, or null if none
Throws:
java.lang.Exception - in case of invalid state or arguments

addDisallowedField

public void addDisallowedField(org.springframework.web.bind.ServletRequestDataBinder binder,
                               java.lang.String field)
Adds ad disallowed field to the list of allowed fields contained by the binder

Parameters:
binder - The binder to which the disallowed field should be added
field - The field that should be disallowed

createEditViews

protected abstract void createEditViews()
Callback to add edit views. Sub classes should implement this method, call the super and invoke addEditViews to add its own edit views to the controller.


createResourceBaseNames

protected abstract void createResourceBaseNames(java.lang.Object command)
Callback to add resource base names. Sub classes should implement this method, call the super and invoke addResourceBaseNames to add its own resource base names to the controller.


addEditView

public void addEditView(WmEditView editView)
Adds an edit view to this controller and removes any edit view that already exists and has the same value. Edit views are used by the showForm to create a wmMultiEditView returned by the showForm

Parameters:
editView - Edit view to add to this controller

addEditViews

public void addEditViews(WmEditView[] editViews)
Adds an array of edit views to this controller and removes any edit view that already exists and has the same value. Edit views are used by the showForm to create a wmMultiEditView returned by the showForm

Parameters:
editViews - Edit views to add to this controller

addResourceBaseName

public void addResourceBaseName(java.lang.String resourceBaseName)
Adds a single resource base name to the list of resource base names for this controller. The resource base names are added to the ReloadableResourceBundleMessageSource in referenceData such that the labels become available also in delegated controllers.

Parameters:
resourceBaseName - Resource base name to add to this controller

getResourceBaseNames

public java.util.ArrayList<java.lang.String> getResourceBaseNames()
Return the resource base names for this controller

Returns:
the resource base names for this controller

getEditViewByValue

public EditView getEditViewByValue(java.lang.String value)
Get the editview with the given value.

Parameters:
value - the value to retrieve the edit view from
Returns:
the requested editview

getEditViews

protected java.util.ArrayList<WmEditView> getEditViews()
Return the array list with all edit views on the current stack

Returns:
Array list with all edit views on the current stack

getEditView

public EditView getEditView()
get the default editview; the edit view with empty value

Returns:
the defalt editview

addControllerDelegation

protected void addControllerDelegation(DelegatedController controller,
                                       FormBackingObject formBackingObject,
                                       javax.servlet.http.HttpServletRequest request)
Adds a sub controller and corresponding form backing object to the local controller delegation map. This controller will delegate all controller logic to each of the sub controllers and form backing objects contained by the map.

Parameters:
controller - Sub controller to delegate controller logic to
formBackingObject - Form backing object to be invoked onto the controller callback methods

removeControllerDelegation

protected void removeControllerDelegation(DelegatedController controller)
Removes a sub controller and corresponding form backing object to the local controller delegation map.

Parameters:
controller - Controller to remove from the map

getControllerDelegationMap

public java.util.LinkedHashMap<DelegatedController,FormBackingObject> getControllerDelegationMap()
Return the sub controller and corresponding form backing objects stored on the local controller delegation map.

Returns:
Map with sub controllers and corresponding form backing objects

addValidator

public void addValidator(org.springframework.validation.Validator validator)
Helper method to add a validator the the list of validators

Parameters:
validator - Validator to add

pushNestedPath

protected void pushNestedPath(org.springframework.validation.BindException errors,
                              FormBackingObject formBackingObject)
Pushes the nested path onto the stack for spring binding. The nested path is determined by the form backing object itself

Parameters:
errors - BindException to push nested path onto
formBackingObject - Form backing object to push the nested path for

popNestedPath

protected void popNestedPath(org.springframework.validation.BindException errors,
                             FormBackingObject formBackingObject)
Pops a nested path from the stack for spring binding. The nested path is determined by the form backing object itself

Parameters:
errors - BindException to pop nested path from
formBackingObject - Form backing object to push the nested path for

getWmSession

public nl.gx.webmanager.foundation.Session getWmSession(javax.servlet.http.HttpServletRequest request)
Returns the webmanager session that the controller uses for handling the request.

Parameters:
request - The request
Returns:
the webmanager session that the controller uses for handling the request.

getWebsiteByRequest

public Website getWebsiteByRequest(javax.servlet.http.HttpServletRequest request)
Get the website according to the webid in the qs.

Parameters:
request - current HTTP request
Returns:
the Website

getEditLanguageLabel

@Deprecated
protected java.lang.String getEditLanguageLabel(java.lang.String label)
Deprecated. It should not be necessary to retrieve a language specific text within the scope of a controller.

Returns a language specific text from the edit language based on the given label.

Parameters:
label - Label used to retrieve the language specific text.
Returns:
A language specific text from the edit language based on the given label.

getVersion

protected java.lang.Integer getVersion(javax.servlet.http.HttpServletRequest request)
Returns the value of the id parameter in the request as the id of the current version.

Parameters:
request - current HTTP request
Returns:
int representing the current version

isReloadWebManager

public boolean isReloadWebManager(javax.servlet.http.HttpServletRequest request)
Returns true if WebManager should be reloaded after completing the request.

Parameters:
request - The http servlet request
Returns:
true if WebManager should be reloaded after completing the request.

setReloadWebManager

public void setReloadWebManager(boolean reloadWebManager,
                                javax.servlet.http.HttpServletRequest request)
Set if WebManager should be reloaded after completing the request.

Parameters:
reloadWebManager - Set to true when WebManager should be reloaded after completing the request.
request - The http servlet request

getWebsite

public static Website getWebsite(nl.gx.webmanager.foundation.Session wmSession)

getEditContext

public EditContext getEditContext()

getPresentationContext

public PresentationContext getPresentationContext()

getServletContextHack

public javax.servlet.ServletContext getServletContextHack()


Copyright © 2007-2011 GX Software BV. All Rights Reserved.