org.springframework.web.jsf
Class FacesContextUtils

java.lang.Object
  extended byorg.springframework.web.jsf.FacesContextUtils

public abstract class FacesContextUtils
extends Object

Convenience methods to retrieve the root WebApplicationContext for a given FacesContext. This is e.g. useful for accessing a Spring context from custom JSF code.

Analogous to Spring's WebApplicationContextUtils for the ServletContext.

Since:
1.1
Author:
Juergen Hoeller
See Also:
ContextLoader, WebApplicationContextUtils

Constructor Summary
FacesContextUtils()
           
 
Method Summary
static WebApplicationContext getRequiredWebApplicationContext(javax.faces.context.FacesContext fc)
          Find the root WebApplicationContext for this web app, which is typically loaded via ContextLoaderListener or ContextLoaderServlet.
static WebApplicationContext getWebApplicationContext(javax.faces.context.FacesContext fc)
          Find the root WebApplicationContext for this web app, which is typically loaded via ContextLoaderListener or ContextLoaderServlet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FacesContextUtils

public FacesContextUtils()
Method Detail

getWebApplicationContext

public static WebApplicationContext getWebApplicationContext(javax.faces.context.FacesContext fc)
Find the root WebApplicationContext for this web app, which is typically loaded via ContextLoaderListener or ContextLoaderServlet.

Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.

Parameters:
fc - FacesContext to find the web application context for
Returns:
the root WebApplicationContext for this web app, or null if none
See Also:
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE

getRequiredWebApplicationContext

public static WebApplicationContext getRequiredWebApplicationContext(javax.faces.context.FacesContext fc)
                                                              throws IllegalStateException
Find the root WebApplicationContext for this web app, which is typically loaded via ContextLoaderListener or ContextLoaderServlet.

Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.

Parameters:
fc - FacesContext to find the web application context for
Returns:
the root WebApplicationContext for this web app
Throws:
IllegalStateException - if the root WebApplicationContext could not be found
See Also:
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE


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