java 在一个浏览器中使用带有多个选项卡的 JSF

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3202604/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 00:47:30  来源:igfitidea点击:

Using JSF with multiple tabs in one browser

javajsficefacesjsf-2

提问by Andrew

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.

默认情况下,JSF 看起来非常“有状态”。我需要允许人们使用我们的应用程序和多个选项卡在应用程序的不同部分做很多事情。

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:

我们目前不使用 ICEfaces,但我刚刚在 ICEfaces 文档中找到了这个:

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

6.5.7. ICEfaces Portlet 和并发 DOM 视图

ICEfaces 提供了一个称为 Concurrent DOM Views 的功能,它控制 ICEfaces 框架是否支持来自同一浏览器的单个应用程序的多个视图。当在 portlet 容器中运行时,ICEfaces 需要将单个门户页面上的单独 portlet 视为不同的视图,因此几乎总是需要(因此最安全)将此参数设置为 true。

例 6.19。在 WEB-INF/web.xml 配置文件中启用 ICEfaces 并发 DOM 视图功能,以便将同一门户页面上的不同 portlet 视为不同的视图

com.icesoft.faces.concurrentDOMViews 真

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?

所以,我想知道这个美妙的声音功能是否可能适用于我现有的 h:forms 或者它是否只适用于 ICEface 组件?

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

任何人都可以提供任何好的建议来让 JSF 应用程序在多个选项卡中工作吗?

采纳答案by BalusC

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

在 JSF 2.0 中,您可以为此使用视图范围,使用@ViewScoped. 您甚至可以定义自定义范围

See also:

也可以看看:

回答by Ryan

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.

我认为 View Scope 在这里不起作用。这个问题特别是关于多浏览器选项卡场景,我对 View Scope 的理解是每个视图(而不是每个选项卡)仍然有一个单独的状态。换句话说,如果您在多个浏览器选项卡中打开同一页面,那么您就有共享状态的风险。

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

这里提到了这一点: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.

似乎这个问题只有两种解决方案:1. CDI/Seam 对话范围(或类似的东西,其中向请求添加了额外的 id)或 2. 坚持请求范围/无状态应用程序。

回答by Bozho

MyFaces orchestrahas a way of dealing with multiple tabs/windows (using the conversationContextget parameter).

MyFaces Orchestra有一种处理多个选项卡/窗口的方法(使用conversationContextget 参数)。

回答by Luca Molteni

Use Seamwith the JSF framework you want.

Seam与您想要的 JSF 框架结合使用。

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

谈话的上下文是完美的使用不同的标签。只需在每个选项卡上开始新对话。:)

Take a look at the Booking demo

看一下Booking 演示