Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Primefaces' p:growl and redirect to a page

hi im kind of new at jsf enviroment, im trying to update a primefaces growl and then redirect to a page from a commandButton action.

 <p:commandButton value="Guardar"  action="#{AgendamientoMBean.procesaAgendamientoJ()}" 
 update="growlDetalle" />  

The managed bean code its

   FacesContext context = FacesContext.getCurrentInstance();
   context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, descripcion, detalle));
   ....
   ....
    return "agp_bandeja_citas_llamadas?faces-redirect=true";

This only redirectme to the page but doesnt show me the growl message, i tested that if change my method to not return the page the message does show..

I was trying to update the growl of the page that im redirecting but thats impossible i guess.

i think that when redirecting i lost the update functionality because im in new page now.

Is there a way to tell jsf to first do the update and then redirecting?

Hope you can help me, thanks in advance

like image 729
arkantos Avatar asked Mar 29 '12 19:03

arkantos


1 Answers

Messages get lost during redirect. You can use the flash to keep messages.

Add the following before returning from your action method:

FacesContext context = FacesContext.getCurrentInstance();
context.getExternalContext().getFlash().setKeepMessages(true);
like image 73
Matt Handy Avatar answered Oct 06 '22 14:10

Matt Handy