开发者

Separate Managed bean for a popup dialog

I have three screens(views) associated with separate managed beans for each view. And, I have a common pop-up dialog which can be opened in all the views.

Can I define a managedbean se开发者_如何转开发parately for the pop-up with state @NoneScoped; and maintain an instance of it in each parent bean?? or

Do I need to maintain pop-up data in all three parent views?

Please, suggest me the best practice.


I think this is what you are looking for (check out the answer by BalusC) -

Whats the correct way to create multiple instances of managed beans in JSF 2.0

And since you are using @NoneScoped (unlike @RequestScoped in the above question), I also recommend you to look at this answer by BalusC (about @NoneScoped) -

what is none scope bean and when to use it?

And according to this answer, you can't maintain any instances of a managedbean that is none-scoped, as they are garbaged as soon as they are used.

So, in your case since you have three separate views, for each view, the bean is constructed and used to build the view and garbaged. (Looks like it does not even last for a request cycle). When you request another view, it will be a separate instance.

To have multiple intances of a bean, you can have three properties in a Session-Scoped been (to make them survive across multiple views).

@ManagedBean 
@SessionScoped 
public class Parent {     
    private Child child1;     
    private Child child2;     
    private Child child3;     

    // ... 
}     
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜