• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsf multiple instances managed bean for multiple tabs

 
dinesh laxman kumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a managed bean(DemoManagedBean.java) which holds some data on the (sample.xhtml)XHTML page.

There is a redirection link in the sample.xhtml which opens a new tab of the same page(sample.xhtml) but with different data loaded.

Issue - since there is only one instance of the DemoManagedBean.java, therefore not able to process anything further i.e; changes on one tab affect all the other tabs.

Is there a way so that I can have a multiple instances for every tab holding the data for the particular tabs?



Thanks in advance
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The fact that one Model can reflect in multiple View is one of the primary strengths of the MVC paradigm, although usually the View are of different types, such as charts and graphs.

To get multiple Views running against Multiple Models, you'd need to qualify the model ID. For example, keep a list of Models, and index each view. That means more complex EL property references in the view, but it cannot be helped.

It actually sounds like you're doing a variation of the old multiple pop-up window scheme, which neither I nor JSF have much fondness for.
 
dinesh laxman kumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resolved -

Just in case someone gets to this thread.

I resolved the issue by using the '@ViewScoped' which created a separate instance for every view. There by the processing in a window did not affect the other window where the same page was opened.

Btw, Thanks Tim
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm. This is interesting. I was always under the impression that View Scope was just a self-deleting version of Session Scope and that therefore there would be only one instance of a View Scope object per session. Getting multiple View Scope objects would mean that the actual internal identifier for the View Scope object wouldn't be the same as it would for a vanilla session-scope object.

I did a little checking, and it seems you may be correct, although I have yet to read the official specs on that. I'll probably end up doing an experiment or 2.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!