I have page1 with button that navigates to page2, page 2 add some messages and navigates back to page1. I want display those messages on page1. I've tried many solutions, but nothing work.
Sample code page1.xhtml:
<p:commandButton value="edit" action="#{bean1.edit}"/>
In the managed bean:
public String edit() {
return "page2?faces-redirect=true";
}
page2 managed bean
@PostConstruct
private void postConstruct() {
Faces.getFlash().setKeepMessages(true);
Messages.addFlashGlobalError("cannot edit!");
Faces.navigate("page1?faces-redirect=true");
}
Both beans are view scoped and both pages have <p:messages>
at the end of body.