Using JSF with multiple tabs in one browser [duplicate]

a 夏天 提交于 2019-11-27 18:16:09

问题


This question already has an answer here:

  • How to choose the right bean scope? 2 answers

By default JSF appears to be very 'stateful'. I need to allow people to use our application with multiple tabs doing many things in different parts of the application.

I can't seem to find decent instruction on making this happen without a whole lot of re-engineering.

We do not currently use ICEfaces, but I just found this in the ICEfaces docs:

6.5.7. ICEfaces Portlets and Concurrent DOM Views

ICEfaces provides a feature called Concurrent DOM Views that controls whether or not the ICEfaces framework supports multiple views of a single application from the same browser. When running in a portlet container, ICEfaces needs to treat the separate portlets on a single portal page as distinct views so it is almost always necessary (and therefore safest) to have this parameter set to true.

Example 6.19. Enabling the ICEfaces Concurrent DOM Views feature in the WEB-INF/web.xml configuration file so that separate portlets on the same portal page are treated as distinct views

com.icesoft.faces.concurrentDOMViews true

So, I want to know whether this fabulous sounding functionality would possibly apply to my existing h:forms or whether it only works with ICEface components?

Can anyone offer any good advice to get a JSF app working in multiple tabs?


回答1:


In JSF 2.0 you can use the view scope for this, annotable using @ViewScoped. You can even define custom scopes.

See also:

  • The benefits and pitfalls of @ViewScoped



回答2:


I don't think View Scope will work here. The question is specifically about a multi-browser tab scenario and my understanding with View Scope is that there is still one separate state per view (not per tab). In other words if you have the same page open in multiple browser tabs then you are at risk for sharing state.

This is mentioned here: http://www.java.net/node/692109

It seems like there are only two solutions to this problem: 1. CDI/Seam conversation scope (or something like it where an extra id is added to requests) or 2. Just stick to request scope / stateless app.




回答3:


MyFaces orchestra has a way of dealing with multiple tabs/windows (using the conversationContext get parameter).




回答4:


Use Seam with the JSF framework you want.

The conversation context is perfect for using different tab. Just start a new conversation on each tab. :)

Take a look at the Booking demo



来源:https://stackoverflow.com/questions/3202604/using-jsf-with-multiple-tabs-in-one-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!