I get an error when I refresh a page displayed during a conversation. How to avoid this error?
The situation:
I have 2 JSF pages, index.xhtml and age.xhtml.
index.xhtml contains a form where the user enter a birthdate (a property of the backing bean "bean"). When the user submits the form, age.xhtml displays the age according to the birthdate.
The form is submitted with a redirection:
<h:commandButton value="Submit" action="#{bean.computeAge()}" />
computeAge method:
conversation.begin();
return "age?faces-redirect=true";
The same backing bean "bean" is used by both pages. This backing bean has a conversation scope.
Page age.xhtml:
Your age: #{bean.age} years
getAge method:
if (!conversation.isTransient()) {
conversation.end();
}
return ejb.computeAge(birthdate);
All is OK, except when I refresh age.xhtml. Then I receive this error message: WELD-000321 No conversation found to restore for id 3
The URL displayed by the browser before and after the refresh:
http://localhost:8080/tpjsf1/faces/age.xhtml?cid=3
The problem comes from cid=3 at the end. Is it possible to avoid the error page when the user refreshes age.xhtml?