org.springframework.web.servlet.mvc
Class AbstractCommandController

java.lang.Object
  extended byorg.springframework.context.support.ApplicationObjectSupport
      extended byorg.springframework.web.context.support.WebApplicationObjectSupport
          extended byorg.springframework.web.servlet.support.WebContentGenerator
              extended byorg.springframework.web.servlet.mvc.AbstractController
                  extended byorg.springframework.web.servlet.mvc.BaseCommandController
                      extended byorg.springframework.web.servlet.mvc.AbstractCommandController
All Implemented Interfaces:
ApplicationContextAware, 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):

Author:
Rod Johnson, 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.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_POST
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
AbstractCommandController()
          Create a new AbstractCommandController.
AbstractCommandController(java.lang.Class commandClass)
          Create a new AbstractCommandController.
AbstractCommandController(java.lang.Class commandClass, java.lang.String commandName)
          Create a new AbstractCommandController.
 
Method Summary
protected abstract  ModelAndView handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.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  ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Template method.
 
Methods inherited from class org.springframework.web.servlet.mvc.BaseCommandController
bindAndValidate, checkCommand, createBinder, createCommand, getCommand, getCommandClass, getCommandName, getValidator, initBinder, isValidateOnBinding, onBind, onBindAndValidate, setCommandClass, setCommandName, setValidateOnBinding, setValidator
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractController
handleRequest, setSynchronizeOnSession
 
Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseExpiresHeader
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, requiredContextClass
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, 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(java.lang.Class commandClass)
Create a new AbstractCommandController.

Parameters:
commandClass - class of the command bean

AbstractCommandController

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

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

handleRequestInternal

protected final ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request,
                                                   javax.servlet.http.HttpServletResponse response)
                                            throws java.lang.Exception
Description copied from class: AbstractController
Template method. Subclasses must implement this. The contract is the same as for handleRequest.

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

handle

protected abstract ModelAndView handle(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response,
                                       java.lang.Object command,
                                       BindException errors)
                                throws java.lang.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.

Can invoke errors.getModel() to populate the ModelAndView model with the command and the Errors instance, under the specified command name.

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


Copyright (C) 2003-2004 The Spring Framework Project.