views:

42

answers:

1

I just introduced Spring in a JSF web application, and now I'm feeling tempted to turn my JSF managed beans into Spring beans by moving these beans to the contextConfigLocation XML file (specifying org.springframework.web.jsf.el.SpringBeanFacesELResolver in faces-config.xml) instead of having the beans in the faces-config.xml file.

I see a lot of advantages if I move to Spring beans (like getting dependency injection functionality) compared against JSF beans so I hardly can argue against moving to Spring beans, but I would like to hear from others what issues I may face if I do this, or what is the best practice for this case.

Thanks.

+3  A: 

The only major issue may be that you're tight-coupling JSF with Spring and that your JSF views/models may not be reuseable anymore without Spring. The only feasible alternative would be upgrading to JSF 2.0 / Java EE 6 and make use of Java EE 6 provided dependency injection facilities instead of relying on a 3rd party DI framework. On the other hand, the current advantages are sound. You can just do so.

BalusC
@BalusC Java EE 6 is not possible right now, I'm restricted to Java EE 5. I think I will try to keep my JSF backing beans as JSF managed beans, for business logic and other services I will use Spring... I haven't checked, but maybe could be possible to declare the beans in faces-config.xml but make a configuration somewhere so these beans are actually handled by Spring (maybe I'm saying something dumb, I am relatively new to Spring and the way I'm declaring my beans is using a contextConfigLocation file).
Abel Morelos