`

Weld中实现ViewScoped

阅读更多
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
分享到:
评论
1 楼 打倒小日本 2010-01-10  
学习外加顶~

相关推荐

Global site tag (gtag.js) - Google Analytics