public class SpringBeanFacesELResolver extends ELResolver
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.SpringBeanFacesELResolver</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>
WebApplicationContextFacesELResolver
,
FacesContextUtils.getRequiredWebApplicationContext(javax.faces.context.FacesContext)
RESOLVABLE_AT_DESIGN_TIME, TYPE
Constructor and Description |
---|
SpringBeanFacesELResolver() |
Modifier and Type | Method and Description |
---|---|
java.lang.Class<?> |
getCommonPropertyType(ELContext elContext,
java.lang.Object base) |
java.util.Iterator<java.beans.FeatureDescriptor> |
getFeatureDescriptors(ELContext elContext,
java.lang.Object base) |
java.lang.Class<?> |
getType(ELContext elContext,
java.lang.Object base,
java.lang.Object property) |
java.lang.Object |
getValue(ELContext elContext,
java.lang.Object base,
java.lang.Object property) |
protected WebApplicationContext |
getWebApplicationContext(ELContext elContext)
Retrieve the web application context to delegate bean name resolution to.
|
boolean |
isReadOnly(ELContext elContext,
java.lang.Object base,
java.lang.Object property) |
void |
setValue(ELContext elContext,
java.lang.Object base,
java.lang.Object property,
java.lang.Object value) |
convertToType, invoke
@Nullable public java.lang.Object getValue(ELContext elContext, @Nullable java.lang.Object base, java.lang.Object property) throws ELException
getValue
in class ELResolver
ELException
@Nullable public java.lang.Class<?> getType(ELContext elContext, @Nullable java.lang.Object base, java.lang.Object property) throws ELException
getType
in class ELResolver
ELException
public void setValue(ELContext elContext, @Nullable java.lang.Object base, java.lang.Object property, java.lang.Object value) throws ELException
setValue
in class ELResolver
ELException
public boolean isReadOnly(ELContext elContext, @Nullable java.lang.Object base, java.lang.Object property) throws ELException
isReadOnly
in class ELResolver
ELException
@Nullable public java.util.Iterator<java.beans.FeatureDescriptor> getFeatureDescriptors(ELContext elContext, @Nullable java.lang.Object base)
getFeatureDescriptors
in class ELResolver
public java.lang.Class<?> getCommonPropertyType(ELContext elContext, @Nullable java.lang.Object base)
getCommonPropertyType
in class ELResolver
protected WebApplicationContext getWebApplicationContext(ELContext elContext)
The default implementation delegates to FacesContextUtils.
elContext
- the current JSF ELContextnull
)FacesContextUtils.getRequiredWebApplicationContext(javax.faces.context.FacesContext)