Board index JavaServer Faces General How to add message to another page?

How to add message to another page?

Components, Ajax Framework, Utilities and More.


Posts: 9
Hi guys, I just started using PrimeFaces it's been a while, and it's so cool, however I can't figure out how to solve a situation let's say :

I have 2 pages listCustomers.jsf and newCustomer.jsf, I'm using newCustomer.jsf to add new customer, and if it is added succefully i need to show a message dialog in a growl in the next page "listCustomers.jsf" telling that the customer has been succefuly added... , however I can't do that since messages are added to the current page "newCustomer.jsf", so is there any way to send the message to the next page?

best regards.
Primefaces 2.2.1
JSF 2.0 Mojarra 2.0.2
Facelets
GlassFish 3.0.1

Oleg User avatar
Expert Member

Posts: 3702
Location: Russia, Siberia => Germany, Black Forest
Hi,

Do you do a redirect to listCustomers.jsf? Why can you not add messages to listCustomers.jsf? If it's quite normally forward navigation and you have messages tag in listCustomers.jsf, you should see the messages there.
PrimeFaces 4.x, 5.x, Mojarra 2.2.x, JBoss WildFly, WebSphere, Windows 8.1, IntelliJ IDEA
PrimeFaces Cookbook: http://ova2.github.com/primefaces-cookbook/ PrimeFaces Extensions on GitHub: http://primefaces-extensions.github.com/


Posts: 15043
Location: Cybertron

Yes, if you do a forward, messages can be displayed in new page, if you do redirect they are gone. If I'm not mistaken, JSF 2's new Flash feature has keepMessages option to survive messages in redirects.
PrimeFaces Lead


Posts: 9
Thank you for fast replay, and in fact i'm doing redirect , I guess that's why i can't get messages in the next page i will try this out right now and confirm it.
Primefaces 2.2.1
JSF 2.0 Mojarra 2.0.2
Facelets
GlassFish 3.0.1


Posts: 9
That 's it! i will use Flash and keep redirect

problem solved :mrgreen: thank you all.
Primefaces 2.2.1
JSF 2.0 Mojarra 2.0.2
Facelets
GlassFish 3.0.1


Posts: 365
Don't expect use of flash to be straightforward, but give it a try.


Posts: 9
I'm using right now Flash with redirect and it works like a charm. cheers thank you again!
Primefaces 2.2.1
JSF 2.0 Mojarra 2.0.2
Facelets
GlassFish 3.0.1


Posts: 723
Location: United States
Once it stops working like a charm (as it did for me), then you'll probably want to take a look here:

http://ocpsoft.com/java/persist-and-pass-facesmessages-over-page-redirects/


Posts: 365
>Once it stops working like a charm (as it did for me), then you'll probably >want to take a look here:

me too!


Posts: 9
well, if you say so i will look at the link emediatly!
Primefaces 2.2.1
JSF 2.0 Mojarra 2.0.2
Facelets
GlassFish 3.0.1


Return to General