Java – JSF CDI: dialog scope bean [S] best practices

I am currently learning JSF 2.0 and am very happy with the existence of this session scope function, which is very useful for opening a new tab or a new window on the same page with separate resources rather than overlapping each other

But the curious thing is how to achieve this. It's good about when to start the conversation and when to close it

In my case, I have each CDI bean for each JSF page Let's say I have a menu. When it is clicked, it will lead to page A. from a can lead to B, B can lead to C, and C can lead to D. all four pages are connected in a chain

It is possible to access the bean properties of a from B or C or D beans, or access the properties of B from C or D beans, and so on

Now I'm confused:

>Should all these a, B, C, d be within the scope of the session, or maybe just a? Because I think sometimes from another page outside the ABCD chain, like a page F, it can navigate to page B, although I don't know how to supply data to bean B yet. > Whether all these a, B, C, D should be merged into one bean > where and when to start the dialogue, I think of the builder, but I don't think it's a good idea, because I like to start the dialogue page when I visit for the first time, rather than bean > when and where to stop the dialogue, so there will be no unused resources hanging around

Please share your thoughts

Solution

JSF 2 provides request, view, session, and application scope CDI introduces conversation scope, but more importantly, it introduces a standard through which new scope can be added to the platform

The range you describe may be more suitable for custom ranges such as window ranges The two projects implementing this scope are:

>Apache myfaces Codi > icefaces has a JSF (non CDI) window scope implementation

However, I encourage you to rethink your bean structure I already like view scope very much, and add JSF 2 view parameters to propagate information from one page to another (and from one view scope instance to another)

Myfaces "view access" scope seems to be another neat method. As long as the page you browse maintains a reference to the scope, the bean will remain in the scope

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>