【发布时间】:2013-04-25 21:30:06
【问题描述】:
刷新对话期间显示的页面时出现错误。如何避免这个错误?
情况:
我有 2 个 JSF 页面,index.xhtml 和 age.xhtml。
index.xhtml 包含一个表单,用户可以在其中输入生日(支持 bean“bean”的属性)。当用户提交表单时,age.xhtml 会根据生日显示年龄。
表单是通过重定向提交的:
<h:commandButton value="Submit" action="#{bean.computeAge()}" />
computeAge 方法:
conversation.begin();
return "age?faces-redirect=true";
两个页面都使用相同的支持 bean“bean”。这个支持 bean 有一个对话范围。
页面年龄.xhtml:
Your age: #{bean.age} years
getAge 方法:
if (!conversation.isTransient()) {
conversation.end();
}
return ejb.computeAge(birthdate);
一切正常,除非我刷新age.xhtml。然后我收到此错误消息: WELD-000321 找不到要恢复 id 3 的对话
刷新前后浏览器显示的URL:
http://localhost:8080/tpjsf1/faces/age.xhtml?cid=3
问题出在最后的 cid=3 上。用户刷新age.xhtml时是否可以避免错误页面?
【问题讨论】: