Class BaseWebmanagerController
- java.lang.Object
-
- org.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
-
- nl.gx.webmanager.springmvc.controller.BaseWebmanagerController
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,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
Fields Modifier and Type Field Description protected Object
formBackingObject
static 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
-
-
Constructor Summary
Constructors Constructor Description BaseWebmanagerController()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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, String field)
Adds ad disallowed field to the list of allowed fields contained by the bindervoid
addEditView(WmEditView editView)
Adds an edit view to this controller and removes any edit view that already exists and has the same value.static ArrayList<WmEditView>
addEditView(WmEditView editView, List<WmEditView> currentEditViews)
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(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 validatorsprotected abstract void
createEditViews()
Callback to add edit views.protected abstract void
createResourceBaseNames(Object command)
Callback to add resource base names.Object
formBackingObject(javax.servlet.http.HttpServletRequest request)
Retrieve a form backing object for the current form from the given request.LinkedHashMap<DelegatedController,FormBackingObject>
getControllerDelegationMap()
Return the sub controller and corresponding form backing objects stored on the local controller delegation map.EditContext
getEditContext()
protected String
getEditLanguageLabel(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 valueEditView
getEditViewByValue(String value)
Get the editview with the given value.protected ArrayList<WmEditView>
getEditViews()
Return the array list with all edit views on the current stackPresentationContext
getPresentationContext()
ArrayList<String>
getResourceBaseNames()
Return the resource base names for this controllerjavax.servlet.ServletContext
getServletContextHack()
protected 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(Session wmSession)
Website
getWebsiteByRequest(javax.servlet.http.HttpServletRequest request)
Get the website according to the webid in the qs.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 controllerboolean
isReloadWebManager(javax.servlet.http.HttpServletRequest request)
Returns true if WebManager should be reloaded after completing the request.void
onBind(javax.servlet.http.HttpServletRequest request, 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, 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, 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.Map<String,Object>
referenceData(javax.servlet.http.HttpServletRequest request, 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, isAlwaysMustRevalidate, isRequireSession, isUseCacheControlHeader, isUseCacheControlNoStore, isUseExpiresHeader, preventCaching, setAlwaysMustRevalidate, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseCacheControlNoStore, setUseExpiresHeader
-
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
-
-
-
-
Field Detail
-
PROTOCOL_PROCESSED_KEY
public static final 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 Object formBackingObject
-
-
Method Detail
-
initialize
public void initialize(javax.servlet.http.HttpServletRequest request)
Initialize the controller- Parameters:
request
-
-
formBackingObject
public 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 classorg.springframework.web.servlet.mvc.AbstractFormController
- Parameters:
request
- current HTTP request- Returns:
- the FormBackingObject
- Throws:
Exception
- in case of invalid state or argumentsjavax.servlet.ServletException
-
initBinder
public void initBinder(javax.servlet.http.HttpServletRequest request, org.springframework.web.bind.ServletRequestDataBinder binder) throws Exception
Initialize the given binder with custom editors for the Date class.- Overrides:
initBinder
in classorg.springframework.web.servlet.mvc.BaseCommandController
- Parameters:
request
- current HTTP requestbinder
- new binder instance- Throws:
Exception
- in case of invalid state or arguments
-
onBind
public void onBind(javax.servlet.http.HttpServletRequest request, Object command, org.springframework.validation.BindException errors) throws 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 classorg.springframework.web.servlet.mvc.BaseCommandController
- Parameters:
request
- current HTTP requestcommand
- the command object to perform further binding onerrors
- validation errors holder, allowing for additional custom registration of binding errors- Throws:
Exception
- in case of invalid state or arguments
-
onBindAndValidate
public void onBindAndValidate(javax.servlet.http.HttpServletRequest request, Object command, org.springframework.validation.BindException errors) throws 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 classorg.springframework.web.servlet.mvc.BaseCommandController
- Parameters:
request
- current HTTP requestcommand
- the command object, still allowing for further bindingerrors
- validation errors holder, allowing for additional custom validation- Throws:
Exception
- in case of invalid state or arguments
-
onSubmit
public void onSubmit(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object command, org.springframework.validation.BindException errors, org.springframework.web.servlet.ModelAndView modelAndView) throws 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 requestresponse
- current servlet responsecommand
- form object with request parameters bound onto iterrors
- Errors instance without errors (subclass can add errors if it wants to)modelAndView
- the model and view prepared by the main spring controller- Throws:
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 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 classorg.springframework.web.servlet.mvc.SimpleFormController
- Parameters:
request
- current http requestresponse
- current http responseerrors
- Errors instance without errors (subclass can add errors if it wants to)- Throws:
Exception
-
referenceData
public Map<String,Object> referenceData(javax.servlet.http.HttpServletRequest request, Object command, org.springframework.validation.Errors errors) throws 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 classorg.springframework.web.servlet.mvc.SimpleFormController
- Parameters:
request
- current HTTP requestcommand
- the command object to perform further binding onerrors
- validation errors holder, allowing for additional custom registration of binding errors- Returns:
- a Map with reference data entries, or
null
if none - Throws:
Exception
- in case of invalid state or arguments
-
addDisallowedField
public void addDisallowedField(org.springframework.web.bind.ServletRequestDataBinder binder, 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 addedfield
- 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(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
-
addEditView
public static ArrayList<WmEditView> addEditView(WmEditView editView, List<WmEditView> currentEditViews)
-
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(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 ArrayList<String> getResourceBaseNames()
Return the resource base names for this controller- Returns:
- the resource base names for this controller
-
getEditViewByValue
public EditView getEditViewByValue(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 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 toformBackingObject
- 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 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 ontoformBackingObject
- 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 fromformBackingObject
- Form backing object to push the nested path for
-
getWmSession
public 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 String getEditLanguageLabel(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 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
-
getEditContext
public EditContext getEditContext()
-
getPresentationContext
public PresentationContext getPresentationContext()
-
getServletContextHack
public javax.servlet.ServletContext getServletContextHack()
-
-