【发布时间】:2014-06-24 00:29:39
【问题描述】:
我使用 JSF2.0 和 WELD-CDI 和 jboss AS7。我在 page-backbean 中使用 CDI@ConversiationScope。 去单页,我用的是menu-item,如图:
<rich:menuItem
label="redirect to page1"
execute="@this"
action="#{myBean.begin}"/>
在这个菜单的动作中,调用下面的方法开始对话,然后重定向到想要的页面:
@Named(value = "myBean")
@ConversationScoped
public class MyBean implements Serializable {
@Inject
private Conversation conversation;
public String begin() {
if (!conversation.isTransient()) {
conversation.end();
}
conversation.setTimeout(“1800000”);
conversation.begin();
return "page1";
}
}
和faces-config.xml:
<navigation-case>
<from-outcome>page1</from-outcome>
<to-view-id>/sample/page1.xhtml</to-view-id>
<redirect/>
</navigation-case>
到目前为止,一切都很好。
但是如果我顺便再次申请,在执行conversation.end()之后,仍然没有改变变量并且变量的所有值都保持。为什么?!
执行 "conversation.end()" 后,变量值未重置。为什么变量未重置?请帮帮我。
【问题讨论】:
-
我相信它的工作方式是结束你的谈话并开始一个新的谈话。您在代码中的哪个位置开始一个新的?
-
我有几个页面,要转到任何特定页面,我使用 menuItem。调用菜单“backBean.begin()”的操作。
标签: jakarta-ee cdi weld conversation-scope