Recently, I come across a situation where we need to inject spring beans into JSF managed beans. I am putting down the integration piece (mostly configuration code snippet) here which has worked for us. Configuration details for individual spring and individual jsf2 are out of scope. Only configuration details of Integration with JSF2 and Spring are mentioned below. If you have any queries, please buzz me.
Step: 1
Add below code snippet in web.xml file of web application project.
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
This listener class is provided by Spring, and it is mainly for use with third party servlets like JSF.
Step: 2
Add below code snippet in faces-config.xml file of web application project. This code snippet should be inside the <application> tag .
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
This resolves name references to Spring defined beans.
Step: 3
Add below code snippet in the spring-application-context.xml file of web application.
<context:component-scan base-package="com.company.application.web.beans" />
By doing this, we could able to inject the spring reference beans into jsf managed beans during the run time.
Step: 1
Add below code snippet in web.xml file of web application project.
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
This listener class is provided by Spring, and it is mainly for use with third party servlets like JSF.
Step: 2
Add below code snippet in faces-config.xml file of web application project. This code snippet should be inside the <application> tag .
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
This resolves name references to Spring defined beans.
Step: 3
Add below code snippet in the spring-application-context.xml file of web application.
<context:component-scan base-package="com.company.application.web.beans" />
By doing this, we could able to inject the spring reference beans into jsf managed beans during the run time.
No comments:
Post a Comment