"Oracle Certified Master, Java EE 5 Enterprise Architect" Certified. TOGAF 9 Foundation Certified. Software Architect with more than 8 years of professional hands-on software development experience; utilizing best practices, Object Oriented designs and open standards in developing Portals and enterprise multi-tier applications. BSc from Jordan University faculty of Engineering & Technology – Electrical Engineer Department. Mohammad is a DZone MVB and is not an employee of DZone and has posted 8 posts at DZone. You can read more from them at their website. View Full User Profile

Spring JSF integration

07.12.2011
| 8553 views |
  • submit to reddit

Integrating Spring with JSF is easy, you just need to follow these steps:

1)In web.xml make sure that you have (context listener + context param) :

<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

<context-param>
<param-name>
contextConfigLocation
</param-name>
<param-value>
/WEB-INF/applicationContext*.xml
</param-value>
</context-param>

2) You need to use “DelegatingVariableResolver” in faces-config.xml:

<faces-config>
<application>
<variable-resolver>
org.springframework.web.jsf.DelegatingVariableResolver
</variable-resolver>
…..
</faces-config>

3) In the managed bean where you want to use the Spring bean, you need to add the Spring bean to the managed bean class as a property:

<managed-bean>
<managed-bean-name>…</managed-bean-name>
<managed-bean-class>…</managed-bean-class>
<managed-bean-scope>…</managed-bean-scope>
<managed-property>
<property-name>manager</property-name>
<value>#{manager}</value>
</managed-property>
</managed-bean>

 

Thats it :)

 

From http://java4you.wordpress.com/2011/07/11/spring-jsf-integration/

Published at DZone with permission of Mohammad Juma, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags: