views:

217

answers:

2

I haven't implemented any code, I'm still working the overall architecture for a new application and this going to be the first time I use JSF+Spring.

I need to put web services in front of the Spring service beans (business logic tier) since these beans could be accessed by other applications besides the presentation tier. While defining the different layers or tiers for the application, I feel unsure about how to integrate JSF (the presentation tier) with Spring (the business tier in this application).

I'm considering to define some sort of common tier or service tier in order to provide the glue code for JSF and Spring, but before that I want to hear from others what have they done or if they have used other frameworks to help with the glue code for this scenario (I already checked Spring MVC/Spring Faces, but I'm not sure if that's what I need since I'm thinking of this application more like JSF-centric than Spring-centric, but maybe you could help me about considering another approach).

Thanks in advance.

+2  A: 

The "glue" is the spring ELResolver, which you must configure in your faces-config.xml:

<application>    
    <!--
        This is the JSF 1.2 ELResolver that delegates to the Spring root
        WebApplicationContext resolving name references to Spring-defined
        beans.
    -->
    <el-resolver>
         org.springframework.web.jsf.el.SpringBeanFacesELResolver
    </el-resolver>
 </application>

This means that each #{bean.property} is handled by the resolving the bean in the spring context.

Bozho
Does this stay the same for JSF 2.0, or is it only for JSf 1.2?
Brian Knoblauch
it should be the same. but I'm not sure, so try it.
Bozho
This looks good, but what if want my JSF application to be as ignorant as possible of Spring? If there is a web service that I can call, do I need to use this SpringBeanFacesELResolver?
Abel Morelos
Maybe a I need to be more specific, what if later I decide to use something else instead of Spring? I want to combine JSF+Spring, but I want to have a very loose integration.
Abel Morelos
then if that "something" has an ELResolver, or it is easy to write such, your switch in terms of integration will be 1 line of config.
Bozho
Thanks, I ended with this answer =)
Abel Morelos
A: 

Bozho's suggestion works for JSF 2.0 nicely as well...

Karl