1

I'm looking for an example using MultiPageMessagesSupport from pretty faces.

<lifecycle>
     <phase-listener>com.ocpsoft.pretty.faces.event.MultiPageMessagesSupport</phase-listener>
</lifecycle>

After a click on a h:commandButton I POST-REDIRECT-GET to my Home with prettyfaces.

I'd like to pass a facesMessages: How do you make this ?

  FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Hey Man The Message is There Youhouhou, So CRAZY!!");
  return "pretty:home";
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
ZheFrench
  • 1,164
  • 3
  • 22
  • 46

1 Answers1

0

FacesMessages are stored as request attributes. Since you execute a redirect, the server will start a new request, so you will loose all the attributes from the last request. You could:

  1. Store the messages in session, retrieve them, store them as request attributes (using FacesContext.getCurrentInstance().addMessage) and remove them from session. This is the naive solution.

  2. Searching more on the net, looks like you can use the FlashScope to solve this problem. Refer to Adding faces message to redirected page using ExternalContext.redirect() and JSF 2.1 Redirect Preserving error message

Community
  • 1
  • 1
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
  • Yeah but i'd like to see how it works with PrettyFaces as it's discussed there : http://ocpsoft.org/docs/prettyfaces/snapshot/en-US/html/navigation.html#navigation.faces_messages – ZheFrench Oct 24 '13 at 16:24
  • The second one is about what i'm trying to do...they juste show the old script Lincoln Baxter writes for pretty faces...then it has been integrated in PrettyFaces...but it's not working, i'm adding com.ocpsoft.pretty.faces.event.MultiPageMessagesSupport as they said on the site "To include the MultiPageMessagesSupport phase listener in your application, just add the following lines to your faces-config.xml" – ZheFrench Oct 24 '13 at 16:47
  • Ok. I'm dumb . I forgot that in home page... Sorry and thanks for your help. – ZheFrench Oct 24 '13 at 17:07