Spring Book – Chapter 13 – Spring and JSF Integration

JSF-centric integration

To achieve JSF-centric way of integration, there are two approaches as detailed below:

  • Using DelegatingVariableResolver
  • Using FacesContextUtils

We will now discuss these two approaches in detail in the following sections.

Using DelegatingVariableResolver

The class DelegatingVariableResolver resides in package org.springframework.web.jsf package. In this approach Spring Framework plugs in as a JSF managed bean provider. First define JSF beans in faces-config.xml as managed beans and refer to the spring beans using the managed-property configuration as shown in Listing 13-4 below.

Listing 13-4. Spring beans declared as managed bean provider

For using the beans managed by the Spring container in different places of your JSF application you can use Spring’s DelegatingVariableResolver to resolve the managed property from Spring application context and then JSF’s IoC injects the bean to the JSF managed bean instance. The DelegatingVariableResolver is declared in faces-confog.xml as shown in Listing 13-5 below.

Listing 13-5. Declaring DelegatingVariableResolver in faces-config.xml

After this, you will have to define the bean in the Spring configuration file as shown in Listing 13-6 below.

Listing 13-6. Declaring Spring managed bean in Spring configuration file

Pictorially this approach using DelegatingVariableResolver using JSF IoC and Spring IoC is as shown in Figure 13-6 below.


Figure 13-6. JSF-centric integration

Page Visitors: 3891

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)

1 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 *