【发布时间】:2012-11-30 06:59:51
【问题描述】:
我使用这篇文章 https://stackoverflow.com/a/13838907 中的提示打开新标签页,但是当我返回旧标签页时,我得到 nullPointerException 并且我的 ViewScoped bean 数据丢失了。
<h:form target="_blank">
<p:commandButton value="open new tab" action="#{otherBean.newTab}" ajax="false" />
</h:form>
<h:form>
<p:commandButton value="this wll cause NPE" action="#{pageBean.action}"/>
</h:form>
单击第一个按钮,返回上一个选项卡,单击第二个按钮。 PageBean 再次创建,所有数据都丢失了。两个 bean 都是 ViewScoped。
【问题讨论】:
-
服务器不知道你是在新窗口中打开页面还是一样,所以它解释你在打开新页面时视图发生了变化。发布为评论,因为我不知道您如何解决它(除了制作有问题的 bean
@SessionScoped。
标签: jsf jakarta-ee jsf-2