Integrating JSF with Spring

2020-03-07 05:09发布

问题:

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.

回答1:

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.