我使用這篇文章中的提示https://stackoverflow.com/a/13838907來打開新標籤,但是當我回到舊標籤時,我得到nullPointerException並且我的ViewScoped bean數據丟失。java ee-JSF 2.0 ViewScoped Bean重定向到新窗口NPE
<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'。 – SJuan76