Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Spring JSF integration

DZone's Guide to

Spring JSF integration

· Java Zone
Free Resource

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

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/

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}