我有一个关于JSF、CDI项目的问题。经过大量研究,我发现在CDI中没有@ViewedScoped
注释。我用基于ajax的页面与对话框解决了这个问题。我想从数据表格传递变量到对话框。为此,我不能使用@RequestedScoped
bean,因为该值在请求结束后被丢弃。有人可以帮我解决吗?我不能使用@SessionScoped
,但我认为这是一种不好的实践。或者只把这个变量保存到会话中,谁知道呢。你们能给我一些提示,如何优雅地解决这个问题吗?
import javax.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class ServiceBean implements Serializable {
...
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean
@ViewScoped
public class SomeBean {
@Inject
ServiceBean serviceBean;
@Postconstruct ...
以下是错误信息:
com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean warDetailBean
@ViewedScoped
注解。但这只是在Java EE 7之前的情况。Java EE 7(JSF 2.2)透明地支持与JSF视图范围(来自javax.faces.bean.ViewScoped
)兼容的视图范围(来自javax.faces.view.ViewScoped
)。 - Tiny