SourceForge.net Logo

de.mindmatters.faces.spring.context.servlet
Class AbstractFacesController

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 byde.mindmatters.faces.spring.context.servlet.AbstractFacesController
All Implemented Interfaces:
ApplicationContextAware, Controller, InitializingBean, ServletContextAware
Direct Known Subclasses:
Action, FacesControllerAdapter, FacesLifecycleController

public abstract class AbstractFacesController
extends AbstractController
implements InitializingBean, ServletContextAware

Convenience superclass for controller implementations, using the Template Method design pattern which creates a FacesContext on the beginning of request handling. The modified DispatcherServlet acts on AbstractFacesController implementations.

Exposed configuration properties:

name default description
lifecycleId LifecycleFactory.DEFAULT_LIFECYCLE the lifecycle id for identifying the proper lifecycle this controller will run in

Author:
Andreas Kuhrwahl
See Also:
DispatcherServlet

Field Summary
protected  org.apache.commons.logging.Log log
          For logging.
 
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator
HEADER_CACHE_CONTROL, HEADER_EXPIRES, HEADER_PRAGMA, METHOD_GET, METHOD_HEAD, METHOD_POST
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
AbstractFacesController()
           
 
Method Summary
 void afterPropertiesSet()
          Initializes the faces lifecycle this controller runs in.
protected  void doAfterExecution(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Template method.
protected  void doBeforeExecution(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Template method.
protected  Lifecycle getLifecycle()
           
protected abstract  ModelAndView handleRequestInternal(FacesContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Template method.
protected  ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Creates a FacesContext and delegates to the corresponding template methods doBeforeExecution, handleRequestInternal, doAfterExecution.
protected  void initFacesController()
          Hook method for subclasses for initialization purposes.
 void setLifecycleId(java.lang.String lifecycleId)
          Sets the lifecycle id for identifying the proper lifecycle this controller will run in.
 void setServletContext(javax.servlet.ServletContext servletContext)
          
 
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, isUseExpiresHeader, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseExpiresHeader
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, isContextRequired
 
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
 

Field Detail

log

protected final org.apache.commons.logging.Log log
For logging.

Constructor Detail

AbstractFacesController

public AbstractFacesController()
Method Detail

afterPropertiesSet

public final void afterPropertiesSet()
Initializes the faces lifecycle this controller runs in.

Specified by:
afterPropertiesSet in interface InitializingBean

initFacesController

protected void initFacesController()
Hook method for subclasses for initialization purposes.


setServletContext

public final void setServletContext(javax.servlet.ServletContext servletContext)

Specified by:
setServletContext in interface ServletContextAware

setLifecycleId

public final void setLifecycleId(java.lang.String lifecycleId)
Sets the lifecycle id for identifying the proper lifecycle this controller will run in. If not set the LifecycleFactory.DEFAULT_LIFECYCLE will be used.

Parameters:
lifecycleId - the lifecycle id for identifying the proper lifecycle

handleRequestInternal

protected final ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request,
                                                   javax.servlet.http.HttpServletResponse response)
                                            throws java.lang.Exception
Creates a FacesContext and delegates to the corresponding template methods doBeforeExecution, handleRequestInternal, doAfterExecution.

Parameters:
request - current HTTP request
response - current HTTP response
Returns:
a ModelAndView to render, or null if handled directly
Throws:
java.lang.Exception - in case of errors
See Also:
doBeforeExecution(HttpServletRequest, HttpServletResponse), handleRequestInternal(FacesContext, HttpServletRequest, HttpServletResponse), doAfterExecution(HttpServletRequest, HttpServletResponse)

handleRequestInternal

protected abstract ModelAndView handleRequestInternal(FacesContext context,
                                                      javax.servlet.http.HttpServletRequest request,
                                                      javax.servlet.http.HttpServletResponse response)
                                               throws java.lang.Exception
Template method. Subclasses must implement this. The contract is the same as for handleRequest.

Parameters:
context - current FacesContext
request - current HTTP request
response - current HTTP response
Returns:
a ModelAndView to render, or null if handled directly
Throws:
java.lang.Exception - in case of errors
See Also:
#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

doBeforeExecution

protected void doBeforeExecution(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response)
                          throws java.lang.Exception
Template method. Subclasses can override this. This method will be invoked before handleRequest.

Parameters:
request - current HTTP request
response - current HTTP response
Throws:
java.lang.Exception - in case of errors
See Also:
handleRequestInternal(HttpServletRequest, HttpServletResponse), handleRequestInternal(FacesContext, HttpServletRequest, HttpServletResponse)

doAfterExecution

protected void doAfterExecution(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response)
                         throws java.lang.Exception
Template method. Subclasses can override this. This method will be invoked after handleRequest.

Parameters:
request - current HTTP request
response - current HTTP response
Throws:
java.lang.Exception - in case of errors
See Also:
handleRequestInternal(HttpServletRequest, HttpServletResponse), handleRequestInternal(FacesContext, HttpServletRequest, HttpServletResponse)

getLifecycle

protected final Lifecycle getLifecycle()
Returns:
the faces lifecycle this controller runs in

SourceForge.net Logo

Copyright © 2002 mindmatters GmbH & Co. KG