Spring Framework

org.springframework.web.jsf.el
Class WebApplicationContextFacesELResolver

java.lang.Object
  extended by javax.el.ELResolver
      extended by org.springframework.web.jsf.el.WebApplicationContextFacesELResolver

public class WebApplicationContextFacesELResolver
extends javax.el.ELResolver

Special JSF 1.2 ELResolver that exposes the Spring WebApplicationContext instance under a variable named "webApplicationContext".

In contrast to SpringBeanFacesELResolver, this ELResolver variant does not resolve JSF variable names as Spring bean names. It rather exposes Spring's root WebApplicationContext itself under a special name, and is able to resolve "webApplicationContext.mySpringManagedBusinessObject" dereferences to Spring-defined beans in that application context.

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

 <application>
   ...
   <el-resolver>org.springframework.web.jsf.el.WebApplicationContextFacesELResolver</el-resolver>
 </application>

Since:
2.5
Author:
Juergen Hoeller
See Also:
SpringBeanFacesELResolver, FacesContextUtils.getWebApplicationContext(javax.faces.context.FacesContext)

Field Summary
protected  org.apache.commons.logging.Log logger
          Logger available to subclasses
static java.lang.String WEB_APPLICATION_CONTEXT_VARIABLE_NAME
          Name of the exposed WebApplicationContext variable: "webApplicationContext".
 
Fields inherited from class javax.el.ELResolver
RESOLVABLE_AT_DESIGN_TIME, TYPE
 
Constructor Summary
WebApplicationContextFacesELResolver()
           
 
Method Summary
 java.lang.Class<?> getCommonPropertyType(javax.el.ELContext elContext, java.lang.Object base)
           
 java.util.Iterator<java.beans.FeatureDescriptor> getFeatureDescriptors(javax.el.ELContext elContext, java.lang.Object base)
           
 java.lang.Class<?> getType(javax.el.ELContext elContext, java.lang.Object base, java.lang.Object property)
           
 java.lang.Object getValue(javax.el.ELContext elContext, java.lang.Object base, java.lang.Object property)
           
protected  WebApplicationContext getWebApplicationContext(javax.el.ELContext elContext)
          Retrieve the WebApplicationContext reference to expose.
 boolean isReadOnly(javax.el.ELContext elContext, java.lang.Object base, java.lang.Object property)
           
 void setValue(javax.el.ELContext elContext, java.lang.Object base, java.lang.Object property, java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEB_APPLICATION_CONTEXT_VARIABLE_NAME

public static final java.lang.String WEB_APPLICATION_CONTEXT_VARIABLE_NAME
Name of the exposed WebApplicationContext variable: "webApplicationContext".

See Also:
Constant Field Values

logger

protected final org.apache.commons.logging.Log logger
Logger available to subclasses

Constructor Detail

WebApplicationContextFacesELResolver

public WebApplicationContextFacesELResolver()
Method Detail

getValue

public java.lang.Object getValue(javax.el.ELContext elContext,
                                 java.lang.Object base,
                                 java.lang.Object property)
                          throws javax.el.ELException
Specified by:
getValue in class javax.el.ELResolver
Throws:
javax.el.ELException

getType

public java.lang.Class<?> getType(javax.el.ELContext elContext,
                                  java.lang.Object base,
                                  java.lang.Object property)
                           throws javax.el.ELException
Specified by:
getType in class javax.el.ELResolver
Throws:
javax.el.ELException

setValue

public void setValue(javax.el.ELContext elContext,
                     java.lang.Object base,
                     java.lang.Object property,
                     java.lang.Object value)
              throws javax.el.ELException
Specified by:
setValue in class javax.el.ELResolver
Throws:
javax.el.ELException

isReadOnly

public boolean isReadOnly(javax.el.ELContext elContext,
                          java.lang.Object base,
                          java.lang.Object property)
                   throws javax.el.ELException
Specified by:
isReadOnly in class javax.el.ELResolver
Throws:
javax.el.ELException

getFeatureDescriptors

public java.util.Iterator<java.beans.FeatureDescriptor> getFeatureDescriptors(javax.el.ELContext elContext,
                                                                              java.lang.Object base)
Specified by:
getFeatureDescriptors in class javax.el.ELResolver

getCommonPropertyType

public java.lang.Class<?> getCommonPropertyType(javax.el.ELContext elContext,
                                                java.lang.Object base)
Specified by:
getCommonPropertyType in class javax.el.ELResolver

getWebApplicationContext

protected WebApplicationContext getWebApplicationContext(javax.el.ELContext elContext)
Retrieve the WebApplicationContext reference to expose.

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

Parameters:
elContext - the current JSF ELContext
Returns:
the Spring web application context
See Also:
FacesContextUtils.getWebApplicationContext(javax.faces.context.FacesContext)

Spring Framework