26.2. Injecting Spring beans into Seam components
You can inject a Spring bean into a Seam component instance either by using an EL expression, or by making the Spring bean a Seam component.
The simplest approach is to access the Spring beans with EL.
The Spring
DelegatingVariableResolver
assists Spring integration with JavaServer Faces (JSF). This VariableResolver
uses EL with bean IDs to make Spring beans available to JSF. You will need to add the DelegatingVariableResolver
to faces-config.xml
:
<application> <variable-resolver> org.springframework.web.jsf.DelegatingVariableResolver </variable-resolver> </application>
You can then inject Spring beans using
@In
:
@In("#{bookingService}") private BookingService bookingService;
Spring beans are not limited to injection. They can be used wherever EL expressions are used in Seam: process and pageflow definitions, working memory assertions, etc.