The Spring Framework

org.springframework.web.jsf.el
Class SpringBeanFacesELResolver

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

public class SpringBeanFacesELResolver
extends javax.el.ELResolver

JSF 1.2 ELResolver that delegates to the Spring root WebApplicationContext, resolving name references to Spring-defined beans.

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

 <application>
   ...
   <el-resolver>org.springframework.web.jsf.el.DelegatingFacesELResolver</el-resolver>
 </application>
All your JSF expressions can then implicitly refer to the names of Spring-managed service layer beans, for example in property values of JSF-managed beans:
 <managed-bean>
   <managed-bean-name>myJsfManagedBean</managed-bean-name>
   <managed-bean-class>example.MyJsfManagedBean</managed-bean-class>
   <managed-bean-scope>session</managed-bean-scope>
   <managed-property>
     <property-name>mySpringManagedBusinessObject</property-name>
     <value>#{mySpringManagedBusinessObject}</value>
   </managed-property>
 </managed-bean>
with "mySpringManagedBusinessObject" defined as Spring bean in applicationContext.xml:
 <bean id="mySpringManagedBusinessObject" class="example.MySpringManagedBusinessObject">
   ...
 </bean>

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

Field Summary
protected  Log logger
          Logger available to subclasses
 
Fields inherited from class javax.el.ELResolver
RESOLVABLE_AT_DESIGN_TIME, TYPE
 
Constructor Summary
SpringBeanFacesELResolver()
           
 
Method Summary
protected  BeanFactory getBeanFactory(javax.el.ELContext elContext)
          Retrieve the Spring BeanFactory to delegate bean name resolution to.
 Class<?> getCommonPropertyType(javax.el.ELContext elContext, Object base)
           
 Iterator<FeatureDescriptor> getFeatureDescriptors(javax.el.ELContext elContext, Object base)
           
 Class<?> getType(javax.el.ELContext elContext, Object base, Object property)
           
 Object getValue(javax.el.ELContext elContext, Object base, Object property)
           
protected  WebApplicationContext getWebApplicationContext(javax.el.ELContext elContext)
          Retrieve the web application context to delegate bean name resolution to.
 boolean isReadOnly(javax.el.ELContext elContext, Object base, Object property)
           
 void setValue(javax.el.ELContext elContext, Object base, Object property, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Logger available to subclasses

Constructor Detail

SpringBeanFacesELResolver

public SpringBeanFacesELResolver()
Method Detail

getValue

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

getType

public Class<?> getType(javax.el.ELContext elContext,
                        Object base,
                        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,
                     Object base,
                     Object property,
                     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,
                          Object base,
                          Object property)
                   throws javax.el.ELException
Specified by:
isReadOnly in class javax.el.ELResolver
Throws:
javax.el.ELException

getFeatureDescriptors

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

getCommonPropertyType

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

getBeanFactory

protected BeanFactory getBeanFactory(javax.el.ELContext elContext)
Retrieve the Spring BeanFactory to delegate bean name resolution to.

The default implementation delegates to getWebApplicationContext. Can be overridden to provide an arbitrary BeanFactory reference to resolve against; usually, this will be a full Spring ApplicationContext.

Parameters:
elContext - the current JSF ELContext
Returns:
the Spring BeanFactory (never null)
See Also:
getWebApplicationContext(javax.el.ELContext)

getWebApplicationContext

protected WebApplicationContext getWebApplicationContext(javax.el.ELContext elContext)
Retrieve the web application context to delegate bean name resolution to.

The default implementation delegates to FacesContextUtils.

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

The Spring Framework

Copyright © 2002-2007 The Spring Framework.