【发布时间】:2012-04-23 07:41:41
【问题描述】:
和here基本一样的问题
如何在重定向到不同浏览器选项卡的页面上保留 ViewScoped bean:
firstPage.xhtml:
<h:commandLink action="#{controller.redirect}" value="#{bean.value} target="_blank"/>
当重定向/导航完成初始化其他 bean 时,它会在进程中销毁这个 #{bean}。在重定向的代码中,我什至没有使用#{bean}。这曾经与
一起使用<a4j:keepAlive>
这是我目前的设置。 豆类:
@ViewScoped
public class Bean{
@PreDestroy
public void onDestroy(){ // being destroyed when I don't want to }
}
面孔配置:
<navigation-rule>
<from-view-id>/firstPage.xhtml</from-view-id>
<navigation-case>
<from-outcome>redirect</from-outcome>
<to-view-id>/secondPage.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
【问题讨论】:
-
该 bean 应该在 @Session 范围内才能工作。作为最后一个资源,您可以在会话中保存数据并在另一个 bean 的构造函数中恢复它。