When integrating Spring and JSF, you really cannot be a novice in any of the technologies because they interact poorly with each other. My first and best advice for you is to get some JSF and Spring books and really understand them separately before trying to integrate them.
With that said, JSF is a component-based web framework with an emphasis on MVC. Spring is an injection of dependencies and an inversion of the control structure, which is not exclusive to web applications.
If you do not understand what these three conditions are:
Then my suggestion is that you just stop acting and start reading right away.
The main problem associated with combining these two things is that between the two structures that need to be solved, there is some overlapping responsibilities. JSF, as a stand-alone structure, supports the volume of its own managed beans without the need for a separate DI structure. With the introduction of Spring, however, there will naturally be conflicts. Spring manages its own beans in addition to JSF, therefore, to reference these ManagedBeans and to correctly enter business objects or DAOs into them, ManagedBeans JSF must become Spring controllers.
You can declare JSF ManagedBean with @Controller annotation. Spring 3 is smart enough to realize that it is a JSF managed bean, and the bean name will be what the name for the ManagedBean is declared.
@Controller @Scope("session") @ManagedBean(name="testBean")
Now that this is being processed, the next problem is that the annoying EL Resolver comes with your JSF implementation. EL Resolver is basically just that, it resolves EL expressions found on your XHTML / JSF page. When referencing testBean however, it will not be able to resolve this name correctly, since it refers to a JSF-managed bean by that name and cannot find the Spring controller with all the Spring entries you need.
Spring 3 solves this problem by providing you with a custom EL Resolver to use instead of what comes bundled with your JSF implementation. You can declare it used in faces-config.xml
<application> <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver> </application>
Now finally:
Should I put some kind of listeners in my web.xml ?!
If you simply integrate JSF + Spring without the need for any other managed Spring servlets or without the need for Spring Security integration, then no you will need anything extra to your web.xml . You will only need to declare FacesServlet and its context parameters, as well as any other third-party library servlets that may be necessary for your situation.