0

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?

user2572526
  • 1,219
  • 2
  • 17
  • 35
  • Why don't you put that message in the session and access that in an another bean !? – Makky Jul 11 '14 at 11:39
  • Which JSF implementation version are you using? [This](http://stackoverflow.com/a/21277621/1199132) answer might be helpful for you. Also if you are only interested in making the Faces messsages survive, [this](http://stackoverflow.com/questions/14242665/how-to-deal-with-jsf-messages-between-page-navigations-post-redirect-get) could also help you. @Makky, what you say does not provide the same behaviour. When using multitab navigation, the Http session is shared, so it would remain in value conflict if user accesses these views from different tabs. – Aritz Jul 12 '14 at 15:56
  • Hi, I'm not sure about what implementation version is in use. During its starting JBoss write this line "[JSFImplManagementDeployer] Initialized 3 JSF configurations: [Mojarra-1.2, MyFaces-2.0, Mojarra-2.0]" so I supposed it's using Mojarra-2.0]. Is there a manner to use a newer version of mojarra in jboss AS 6.0 for my application? thanks – user2572526 Jul 14 '14 at 08:17
  • Ok I think that the problem is caused by the old Mojarra version. How can obtain to send a message to the next page without the use of flashScope? Before the flashscope introduction this behavior was obtained saving the message into the session and then retrieving it in the next page or there was a better manner? – user2572526 Jul 21 '14 at 14:50

0 Answers0