将JSF Managed Beans移动到Spring bean [英] Moving JSF Managed Beans to Spring beans

查看:128
本文介绍了将JSF Managed Beans移动到Spring bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在JSF Web应用程序中介绍了Spring,现在我很想通过将这些bean移动到contextConfigLocation XML文件(指定org.springframework.web.jsf.el)来将我的JSF托管bean转换为Spring bean。在faces-config.xml文件中使用SpringBeanFacesELResolver而不是在faces-config.xml文件中使用bean。

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.

如果我转移到Spring bean,我会看到很多优点(比如获取依赖注入功能)与JSF bean比较,所以我几乎不能反对转移到Spring bean,但我想听听其他人如果我这样做会遇到什么问题,或者这个案例的最佳做法是什么。

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.

推荐答案

唯一的主要问题可能是您将JSF与Spring紧密耦合,并且您的JSF视图/模型可能不会没有Spring就可以重复使用了。唯一可行的替代方案是升级到JSF 2.0 / Java EE 6并使用Java EE 6提供的依赖注入工具,而不是依赖于第三方DI框架。另一方面,当前的优点是合理的。你可以这样做。

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.

这篇关于将JSF Managed Beans移动到Spring bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆