org.springframework.web.portlet.mvc
Class AbstractCommandController

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.portlet.context.PortletApplicationObjectSupport
          extended by org.springframework.web.portlet.handler.PortletContentGenerator
              extended by org.springframework.web.portlet.mvc.AbstractController
                  extended by org.springframework.web.portlet.mvc.BaseCommandController
                      extended by org.springframework.web.portlet.mvc.AbstractCommandController
All Implemented Interfaces:
ApplicationContextAware, PortletContextAware, Controller

public abstract class AbstractCommandController
extends BaseCommandController

Abstract base class for custom command controllers. Autopopulates a command bean from the request. For command validation, a validator (property inherited from BaseCommandController) can be used.

This command controller should preferrable not be used to handle form submission, because functionality for forms is more offered in more detail by the AbstractFormController and its corresponding implementations.

Exposed configuration properties (and those defined by superclass):
none (so only those available in superclass).

Workflow (and that defined by superclass):

Since:
2.0
Author:
John A. Lewis, Juergen Hoeller
See Also:
BaseCommandController.setCommandClass(java.lang.Class), BaseCommandController.setCommandName(java.lang.String), BaseCommandController.setValidator(org.springframework.validation.Validator)

Field Summary
 
Fields inherited from class org.springframework.web.portlet.mvc.BaseCommandController
DEFAULT_COMMAND_NAME
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
AbstractCommandController()
          Create a new AbstractCommandController.
AbstractCommandController(Class commandClass)
          Create a new AbstractCommandController.
AbstractCommandController(Class commandClass, String commandName)
          Create a new AbstractCommandController.
 
Method Summary
protected  String getCommandInSessionParameterName()
          Return the name of the render parameter that indicates there is a valid command (and errors) object in the session.
protected abstract  void handleAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response, Object command, BindException errors)
          Template method for request handling, providing a populated and validated instance of the command class, and an Errors object containing binding and validation errors.
protected  void handleActionRequestInternal(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)
          Subclasses are meant to override this method if the controller is expected to handle action requests.
protected abstract  ModelAndView handleRender(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, Object command, BindException errors)
          Template method for render request handling, providing a populated and validated instance of the command class, and an Errors object containing binding and validation errors.
protected  ModelAndView handleRenderRequestInternal(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
          Subclasses are meant to override this method if the controller is expected to handle render requests.
protected  boolean isCommandInSession(javax.portlet.RenderRequest request)
          Determine if there is a valid command (and errors) object in the session for this render request.
protected  void setCommandInSession(javax.portlet.ActionResponse response)
          Set the action response parameter that indicates there is a command (and errors) object in the session for the render phase.
 
Methods inherited from class org.springframework.web.portlet.mvc.BaseCommandController
bindAndValidate, checkCommand, createBinder, createCommand, getBindingErrorProcessor, getCommand, getCommandClass, getCommandName, getMessageCodesResolver, getPropertyEditorRegistrars, getRenderCommand, getRenderCommandSessionAttributeName, getRenderErrors, getRenderErrorsSessionAttributeName, getValidator, getValidators, getWebBindingInitializer, initApplicationContext, initBinder, isValidateOnBinding, onBind, onBind, onBindAndValidate, prepareBinder, setBindingErrorProcessor, setCommandClass, setCommandName, setMessageCodesResolver, setPropertyEditorRegistrar, setPropertyEditorRegistrars, setRenderCommandAndErrors, setValidateOnBinding, setValidator, setValidators, setWebBindingInitializer, suppressBinding, suppressValidation, useDirectFieldAccess
 
Methods inherited from class org.springframework.web.portlet.mvc.AbstractController
handleActionRequest, handleRenderRequest, isRenderWhenMinimized, isSynchronizeOnSession, setRenderWhenMinimized, setSynchronizeOnSession
 
Methods inherited from class org.springframework.web.portlet.handler.PortletContentGenerator
applyCacheSeconds, cacheForSeconds, check, checkAndPrepare, checkAndPrepare, getCacheSeconds, isRequireSession, preventCaching, setCacheSeconds, setRequireSession
 
Methods inherited from class org.springframework.web.portlet.context.PortletApplicationObjectSupport
getPortletContext, getTempDir, isContextRequired, setPortletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCommandController

public AbstractCommandController()
Create a new AbstractCommandController.


AbstractCommandController

public AbstractCommandController(Class commandClass)
Create a new AbstractCommandController.

Parameters:
commandClass - class of the command bean

AbstractCommandController

public AbstractCommandController(Class commandClass,
                                 String commandName)
Create a new AbstractCommandController.

Parameters:
commandClass - class of the command bean
commandName - name of the command bean
Method Detail

handleActionRequestInternal

protected final void handleActionRequestInternal(javax.portlet.ActionRequest request,
                                                 javax.portlet.ActionResponse response)
                                          throws Exception
Description copied from class: AbstractController
Subclasses are meant to override this method if the controller is expected to handle action requests. The contract is the same as for handleActionRequest.

The default implementation throws a PortletException.

Overrides:
handleActionRequestInternal in class AbstractController
Throws:
Exception
See Also:
AbstractController.handleActionRequest(javax.portlet.ActionRequest, javax.portlet.ActionResponse), AbstractController.handleRenderRequestInternal(javax.portlet.RenderRequest, javax.portlet.RenderResponse)

handleRenderRequestInternal

protected final ModelAndView handleRenderRequestInternal(javax.portlet.RenderRequest request,
                                                         javax.portlet.RenderResponse response)
                                                  throws Exception
Description copied from class: AbstractController
Subclasses are meant to override this method if the controller is expected to handle render requests. The contract is the same as for handleRenderRequest.

The default implementation throws a PortletException.

Overrides:
handleRenderRequestInternal in class AbstractController
Throws:
Exception
See Also:
AbstractController.handleRenderRequest(javax.portlet.RenderRequest, javax.portlet.RenderResponse), AbstractController.handleActionRequestInternal(javax.portlet.ActionRequest, javax.portlet.ActionResponse)

handleAction

protected abstract void handleAction(javax.portlet.ActionRequest request,
                                     javax.portlet.ActionResponse response,
                                     Object command,
                                     BindException errors)
                              throws Exception
Template method for request handling, providing a populated and validated instance of the command class, and an Errors object containing binding and validation errors.

Call errors.getModel() to populate the ModelAndView model with the command and the Errors instance, under the specified command name, as expected by the "spring:bind" tag.

Parameters:
request - current action request
response - current action response
command - the populated command object
errors - validation errors holder
Throws:
Exception
See Also:
Errors, BindException.getModel()

handleRender

protected abstract ModelAndView handleRender(javax.portlet.RenderRequest request,
                                             javax.portlet.RenderResponse response,
                                             Object command,
                                             BindException errors)
                                      throws Exception
Template method for render request handling, providing a populated and validated instance of the command class, and an Errors object containing binding and validation errors.

Call errors.getModel() to populate the ModelAndView model with the command and the Errors instance, under the specified command name, as expected by the "spring:bind" tag.

Parameters:
request - current render request
response - current render response
command - the populated command object
errors - validation errors holder
Returns:
a ModelAndView to render, or null if handled directly
Throws:
Exception
See Also:
Errors, BindException.getModel()

getCommandInSessionParameterName

protected String getCommandInSessionParameterName()
Return the name of the render parameter that indicates there is a valid command (and errors) object in the session.

Returns:
the name of the render parameter
See Also:
PortletRequest.getParameter(java.lang.String)

setCommandInSession

protected final void setCommandInSession(javax.portlet.ActionResponse response)
Set the action response parameter that indicates there is a command (and errors) object in the session for the render phase.

Parameters:
response - the current action response
See Also:
getCommandInSessionParameterName(), isCommandInSession(javax.portlet.RenderRequest)

isCommandInSession

protected boolean isCommandInSession(javax.portlet.RenderRequest request)
Determine if there is a valid command (and errors) object in the session for this render request.

Parameters:
request - current render request
Returns:
if there is a valid command object in the session
See Also:
getCommandInSessionParameterName(), setCommandInSession(javax.portlet.ActionResponse)


Copyright © 2002-2008 The Spring Framework.