JSF2提供了ViewScoped范围,但由于ViewScope仅仅是JSF的概念,所以为了不绑定视图技术,CDI里面没有ViewScoped这个范围。并且,如果用@Named声明Web Bean,那么同时使用JSF2的ViewScoped是没有用的。那么怎么在Weld里面使用ViewScoped呢。JavaRanch上遇到了明白人,解决方案是扩展Weld,实现这个ViewScoped。
原文地址:http://www.verborgh.be/articles/2010/01/06/porting-the-viewscoped-jsf-annotation-to-cdi/
Porting the ViewScoped JSF annotation to CDI
As you might know, JavaServer Faces 2 comes with some optional annotations. Optional, because halfway throught the specification process something called Dependency Injection for Java (JSR330) and something else called Context and Dependency Injection or CDI (JSR299) came to life. That means we have some very usefull annotations like @ViewScoped that are specified in the JSF 2 specification that have no alternatives in CDI.
......
附注,文中提到的javax.enterprise.inject.spi.Extension文件,内容应该写我们事先的Extension的全类名,放在WEB-INF/classes/META-INF/services下。
关于javax.enterprise.inject.spi.Extension的相关信息,见GK老大的文字和Weld的文档:
http://in.relation.to/Bloggers/CDIPortableExtensionExamples
原文地址:http://www.verborgh.be/articles/2010/01/06/porting-the-viewscoped-jsf-annotation-to-cdi/
Porting the ViewScoped JSF annotation to CDI
As you might know, JavaServer Faces 2 comes with some optional annotations. Optional, because halfway throught the specification process something called Dependency Injection for Java (JSR330) and something else called Context and Dependency Injection or CDI (JSR299) came to life. That means we have some very usefull annotations like @ViewScoped that are specified in the JSF 2 specification that have no alternatives in CDI.
......
附注,文中提到的javax.enterprise.inject.spi.Extension文件,内容应该写我们事先的Extension的全类名,放在WEB-INF/classes/META-INF/services下。
关于javax.enterprise.inject.spi.Extension的相关信息,见GK老大的文字和Weld的文档:
http://in.relation.to/Bloggers/CDIPortableExtensionExamples
本文介绍如何将JSF2中的ViewScoped范围移植到CDI环境中,并通过扩展Weld来实现这一目标。文章指出,由于ViewScoped是JSF特有的概念,在CDI中并不存在对应的范围,因此需要进行特定的移植工作。

376

被折叠的 条评论
为什么被折叠?



