I'm using JSF 2.0, primefaces 5 and JBoss AS 6 (at start it displays this message:"[JSFImplManagementDeployer] Initialized 3 JSF configurations: [Mojarra-1.2, MyFaces-2.0, Mojarra-2.0]") and I'm trying to send a message to the next page using JSF2 flashScope. This is the ManagedBean of the first page:
if (error) {
FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, "An error has occurred", "Please try again.");
FacesContext facesContext = FacesContext.getCurrentInstance();
Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
flash.setKeepMessages(true);
flash.setRedirect(true);
flash.putNow("message", facesMessage);
facesContext.addMessage(null, facesMessage);
try {
facesContext.getExternalContext().redirect("index.xhtml");
}
catch (IOException ex) {
logger.error("IOException during redirection to the home");
}
}
In my index.xhtml page (that is the page were I want to show the message) I inserted the tag:
...
<ui:define name="top">
<p:messages />
...
The redirection works if an error occurs but the message is not displayed. What is wrong? Have I to write some code in the destination page ManagedBean?