org.springframework.web.servlet.mvc
Class ParameterizableViewController

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.ParameterizableViewController
All Implemented Interfaces:
ApplicationContextAware, Controller

public class ParameterizableViewController
extends AbstractController

Trivial controller that always returns a named view. The view can be configured using an exposed configuration property. This controller offers an alternative to sending a request straight to a view such as a JSP. The advantage here is, that you're decoupling the controller and the view, letter the some the configuration determine (instead of the controller) the viewtechnology.

An alternative to the ParameterizableViewController is of the MultiAction controllers, some of which allow the same behavior, but then for more views at in one controller.

Workflow (and that defined by superclass):

  1. Request is received by the controller
  2. call to handleRequestInternal which just returns the view, named by the configuration property viewName. Nothing more, nothing less

Exposed configuration properties (and those defined by superclass):

name default description
viewName null the name of the view the viewResolver will use to forward to (if this property is not set, an exception will be thrown during initialization)

Author:
Rod Johnson

Field Summary
 
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
ParameterizableViewController()
           
 
Method Summary
 java.lang.String getViewName()
           
protected  ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Template method.
protected  void initApplicationContext()
          Subclasses can override this for custom initialization behavior.
 void setViewName(java.lang.String viewName)
          Set the view name to return.
 
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, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterizableViewController

public ParameterizableViewController()
Method Detail

setViewName

public void setViewName(java.lang.String viewName)
Set the view name to return.


getViewName

public java.lang.String getViewName()

handleRequestInternal

protected ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request,
                                             javax.servlet.http.HttpServletResponse response)
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
See Also:
AbstractController.handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

initApplicationContext

protected void initApplicationContext()
Description copied from class: ApplicationObjectSupport
Subclasses can override this for custom initialization behavior. Gets called by setApplicationContext() after setting the context instance.

Note: Does not get called on reinitialization of the context.

Overrides:
initApplicationContext in class ApplicationObjectSupport


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