public class

WebApplicationContextVariableResolver

extends VariableResolver
java.lang.Object
   ↳ VariableResolver
     ↳ org.springframework.web.jsf.WebApplicationContextVariableResolver

Class Overview

Special JSF 1.1 VariableResolver that exposes the Spring WebApplicationContext instance under a variable named "webApplicationContext".

In contrast to DelegatingVariableResolver, this VariableResolver does not resolve JSF variable names as Spring bean names. It rather exposes Spring's root WebApplicationContext itself under a special name. JSF-managed beans can then use Spring's WebApplicationContext API to retrieve Spring-managed beans, access resources, etc.

Configure this resolver in your faces-config.xml file as follows:

 <application>
   ...
   <variable-resolver>org.springframework.web.jsf.WebApplicationContextVariableResolver</variable-resolver>
 </application>

Summary

Constants
String WEB_APPLICATION_CONTEXT_VARIABLE_NAME Name of the exposed WebApplicationContext variable: "webApplicationContext".
Fields
protected final VariableResolver originalVariableResolver
Public Constructors
WebApplicationContextVariableResolver(VariableResolver originalVariableResolver)
Create a new WebApplicationContextVariableResolver, using the given original VariableResolver.
Public Methods
Object resolveVariable(FacesContext context, String name)
Check for the special "webApplicationContext" variable first, then delegate to the original VariableResolver.
Protected Methods
final VariableResolver getOriginalVariableResolver()
Return the original JSF VariableResolver that this resolver delegates to.
WebApplicationContext getWebApplicationContext(FacesContext facesContext)
Retrieve the WebApplicationContext reference to expose.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String WEB_APPLICATION_CONTEXT_VARIABLE_NAME

Name of the exposed WebApplicationContext variable: "webApplicationContext".

Constant Value: "webApplicationContext"

Fields

protected final VariableResolver originalVariableResolver

Public Constructors

public WebApplicationContextVariableResolver (VariableResolver originalVariableResolver)

Create a new WebApplicationContextVariableResolver, using the given original VariableResolver.

A JSF implementation will automatically pass its original resolver into the constructor of a configured resolver, provided that there is a corresponding constructor argument.

Parameters
originalVariableResolver the original VariableResolver

Public Methods

public Object resolveVariable (FacesContext context, String name)

Check for the special "webApplicationContext" variable first, then delegate to the original VariableResolver.

If no WebApplicationContext is available, all requests will be delegated to the original VariableResolver.

Throws
EvaluationException

Protected Methods

protected final VariableResolver getOriginalVariableResolver ()

Return the original JSF VariableResolver that this resolver delegates to. Used to resolve standard JSF-managed beans.

protected WebApplicationContext getWebApplicationContext (FacesContext facesContext)

Retrieve the WebApplicationContext reference to expose.

The default implementation delegates to FacesContextUtils, returning null if no WebApplicationContext found.

Parameters
facesContext the current JSF context
Returns
  • the Spring web application context