Spring Web Flow

org.springframework.faces.webflow
Class SpringBeanWebFlowVariableResolver

java.lang.Object
  extended by javax.faces.el.VariableResolver
      extended by org.springframework.faces.webflow.SpringBeanWebFlowVariableResolver

public class SpringBeanWebFlowVariableResolver
extends javax.faces.el.VariableResolver

JSF 1.1 VariableResolver that delegates to the flow's local Spring bean factory (for resolving Spring beans) and then to the original resolver of the underlying JSF implementation (for resolving managed-bean objects as defined in faces-config.xml as well as well-known implicit EL attributes).

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

 <application>
   ...
   <variable-resolver>org.springframework.faces.webflow.SpringBeanWebFlowVariableResolver</variable-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>

Author:
Jeremy Grelle

Field Summary
protected  org.apache.commons.logging.Log logger
          Logger available to subclasses
protected  javax.faces.el.VariableResolver originalVariableResolver
           
 
Constructor Summary
SpringBeanWebFlowVariableResolver(javax.faces.el.VariableResolver originalVariableResolver)
           
 
Method Summary
protected  org.springframework.beans.factory.BeanFactory getBeanFactory(javax.faces.context.FacesContext facesContext)
           
protected  javax.faces.el.VariableResolver getOriginalVariableResolver()
          Return the original JSF VariableResolver that this resolver delegates to.
protected  java.lang.Object resolveOriginal(javax.faces.context.FacesContext facesContext, java.lang.String name)
          Resolve the attribute via the original JSF VariableResolver.
protected  java.lang.Object resolveSpringBean(javax.faces.context.FacesContext facesContext, java.lang.String name)
          Resolve the attribute as a Spring bean in the ApplicationContext.
 java.lang.Object resolveVariable(javax.faces.context.FacesContext facesContext, java.lang.String name)
          Try to resolve the variable as Spring bean in the flow local bean factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

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


originalVariableResolver

protected final javax.faces.el.VariableResolver originalVariableResolver
Constructor Detail

SpringBeanWebFlowVariableResolver

public SpringBeanWebFlowVariableResolver(javax.faces.el.VariableResolver originalVariableResolver)
Method Detail

getOriginalVariableResolver

protected final javax.faces.el.VariableResolver getOriginalVariableResolver()
Return the original JSF VariableResolver that this resolver delegates to. Used to resolve standard JSF-managed beans.


resolveVariable

public java.lang.Object resolveVariable(javax.faces.context.FacesContext facesContext,
                                        java.lang.String name)
                                 throws javax.faces.el.EvaluationException
Try to resolve the variable as Spring bean in the flow local bean factory. Then delegate to the original VariableResolver.

Specified by:
resolveVariable in class javax.faces.el.VariableResolver
Throws:
javax.faces.el.EvaluationException

resolveOriginal

protected java.lang.Object resolveOriginal(javax.faces.context.FacesContext facesContext,
                                           java.lang.String name)
Resolve the attribute via the original JSF VariableResolver.


resolveSpringBean

protected java.lang.Object resolveSpringBean(javax.faces.context.FacesContext facesContext,
                                             java.lang.String name)
Resolve the attribute as a Spring bean in the ApplicationContext.


getBeanFactory

protected org.springframework.beans.factory.BeanFactory getBeanFactory(javax.faces.context.FacesContext facesContext)

Spring Web Flow