Spring Book – Chapter 13 – Spring and JSF Integration

JSF and Spring

Coming straight to integration approaches, there are two approaches possible as below:

  • Spring-centric integration
  • JSF-centric integration

Spring-centric integration

With latest release of Spring (later than Spring version 2.x), Spring Framework has a capability of handling JSF backing beans in its IoC container avoiding JSF IoC container in all aspects and making using of strong Spring IoC for managing beans in a JSF application. By using this you can completely avoid putting the bean declaration in the faces-config.xml file and use the Spring configuration file instead. The following steps needs to be done to achieve this Spring-centric approach:

  • Declare the DelegatingVariableReslver in the faces-config.xml file as shown in Listing 13-1 below.

Listing 13-1. Declaring DelegatingVariableResolver in faces-config.xml file

  • Declare your backing bean as well as Spring bean in the Spring configuration file as shown in Listing 13-2 below.

Listing 13-2. Declaring backing bean and Spring bean in Spring configuration file

  • Declaring appropriate listeners in the web application context file web.xml as shown in Listing 13-3 below.

Listing 13-3. Configuring listeners in the web.xml file of your JSF application

Pictorially this Spring-centric approach can be depicted as shown in Figure 13-5 below.

fig13-05

Figure 13-5. Spring-centric integration

This approach is referred from a blog entry written in the following URL which seemed very logical; http://cagataycivici.wordpress.com/2007/09/10/using-spring-to-manage-jsf-beans/. You can have a complete working sample of this approach in this blog entry.

Page Visitors: 2792

The following two tabs change content below.
Tomcy John

Tomcy John

Blogger & Author at javacodebook
He is an Enterprise Java Specialist holding a degree in Engineering (B-Tech) with over 10 years of experience in several industries. He's currently working as Principal Architect at Emirates Group IT since 2005. Prior to this he has worked with Oracle Corporation and Ernst & Young. His main specialization is on various web technologies and acts as chief mentor and Architect to facilitate incorporating Spring as Corporate Standard in the organization.
Tomcy John

Latest posts by Tomcy John (see all)

One thought on “Spring Book – Chapter 13 – Spring and JSF Integration

  1. Hey very cool blog!! Man .. Excellent .. Wonderful .. I will bookmark your blog and take the feeds also?I’m happy to find a lot of helpful info right here in the put up, we need develop extra techniques in this regard, thank you for sharing. . . . . .

Leave a Reply

Your email address will not be published. Required fields are marked *