org.springframework.web.jsf
Class WebApplicationContextVariableResolver

public class WebApplicationContextVariableResolver
extends VariableResolver
Special 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>
Since1.2.5
VersionNot specified.
AuthorColin Sampaleanu, Juergen Hoeller
Wiki javadoc Use textile entry format.
Add your comments here.
Field Summary
protected VariableResolver originalVariableResolver
No description provided.
static String WEB_APPLICATION_CONTEXT_VARIABLE_NAME
Name of the exposed WebApplicationContext variable: "webApplicationContext".
Constructor Summary
WebApplicationContextVariableResolver( VariableResolver originalVariableResolver )
Create a new WebApplicationContextVariableResolver, using the given original VariableResolver.
Method Summary
protected VariableResolver getOriginalVariableResolver()
Return the original JSF VariableResolver that this resolver delegates to.
protected WebApplicationContext getWebApplicationContext( FacesContext facesContext )
Retrieve the WebApplicationContext reference to expose.
Object resolveVariable( FacesContext context, String name )
Check for the special "webApplicationContext" variable first, then delegate to the original VariableResolver.
originalVariableResolver
protected VariableResolver originalVariableResolver
No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
WEB_APPLICATION_CONTEXT_VARIABLE_NAME
public static String WEB_APPLICATION_CONTEXT_VARIABLE_NAME
Name of the exposed WebApplicationContext variable: "webApplicationContext".
Wiki javadoc Use textile entry format.
Add your comments here.
WebApplicationContextVariableResolver
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
TypeNameDescription
VariableResolver originalVariableResolver the original VariableResolver
Wiki javadoc Use textile entry format.
Add your comments here.
getOriginalVariableResolver
protected VariableResolver getOriginalVariableResolver ( )
Return the original JSF VariableResolver that this resolver delegates to. Used to resolve standard JSF-managed beans.
Wiki javadoc Use textile entry format.
Add your comments here.
getWebApplicationContext
protected WebApplicationContext getWebApplicationContext ( FacesContext facesContext )
Retrieve the WebApplicationContext reference to expose.

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

Parameters
TypeNameDescription
FacesContext facesContext the current JSF context
Wiki javadoc Use textile entry format.
Add your comments here.
resolveVariable
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.

Overrides method in VariableResolver
Parameters
TypeNameDescription
FacesContext context No description provided.
String name No description provided.
Exceptions
EvaluationException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.