views:

92

answers:

0

I have one page that does something and when the user clicks a button, the user is redirected to another page and a message is displayed. Here is my code:

 public String confirm() {
    FacesContext context = FacesContext.getCurrentInstance();
    Flash flash = context.getExternalContext().getFlash();
    flash.setKeepMessages(true);
    FacesMessage msg = new FacesMessage("Succesful", "Release is confirmed!");
    context.addMessage(null, msg);
    return "/prot/expert/releases?faces-redirect=true";
 }

I use a p:growl component which displays my message on the "releases" page. So far so good.

But then on any subsequent page that has p:growl (or if I go to another page and go back) the message is displayed again and again and I can't kill it.

I tried something like:

<c:set target="#{flash}" property="keepMessages" value="false" />

on the page that has the p:growl, I tried clearing the flash from the backing bean etc.

The message is retained and displayed all over again. If I remove flash.setKeepMessages(true); from the code above then nothing is displayed.

What am I doing wrong?