Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

viewScoped bean, if I open new windows what happens?  RSS feed

 
massimo tarantelli
Ranch Hand
Posts: 35
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, as some other posts of mine an other basic question.
if I have a webpage based on a viewScoped bean in the back, than from this page I open a new one that will appear in front of the first, what happens?
are the viewScoped bean destroyed just one the user clic on the close page?
thanks guys
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the first thing that happens is that I scream at the application. Pop-up pages really annoy me.

Besides, my browser doesn't actually pop up - it opens them in new tabs, and when the option is available, it does so without switching to the new window (or tab).

In a purely academic sense, opening a new window would be opening a new View. That is, after all, one of the tenets of MVC - that you can have multiple Views (usually in different forms) of the same Model at the same time.

In a more practical sense, the View Scope is really a special version of Session Scope, where JSF tells the session to remove the backing bean when the user navigates away from that view. What that means in real terms is that the results are somewhat unpredictable, but a strong likelihood exists that if the user closes either of those 2 windows, the backing bean will be immediately purged and the remaining window will start to malfunction.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I take that back. JSF doesn't know when you close a window, since window-close events don't get sent to webservers. But it will definitely know when you depart the page for a new page in either window.
 
massimo tarantelli
Ranch Hand
Posts: 35
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, the viewScoped Bean is destroyed if and only if in the same windows there is a page switch?
thanks again
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know, if you switch the view in any window, the view-scope bean will get destroyed, even if there are other windows open still using it.

JSF doesn't really favor popping open multiple windows.
 
massimo tarantelli
Ranch Hand
Posts: 35
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks again
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!