Viewscoped JSF and CDI bean

岁酱吖の 提交于 2019-12-05 05:34:53

The CDI @Inject works "everywhere" and thus also inside JSF @ManagedBean. The JSF counterpart @ManagedProperty works inside @ManagedBean only. You also can't @Inject a true JSF managed bean in any CDI managed bean (instead, it would be a CDI managed instance). Perhaps this is what you was reading about. General consensus, however, is indeed to preferably not mix them to avoid confusion among starters. JSF utility library OmniFaces has a CDI compatible @ViewScoped for JSF 2.0/2.1.

The @PreDestroy is by the way not specific to CDI, neither is its counterpart @PostConstruct. They should work just fine in both CDI managed beans and JSF managed beans.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!