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.
Add another growl to page you redirect
like this
<p:growl id="growlmsg2" showDetail="true" sticky="true" autoUpdate="true"/>
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);
Because Flash has bug, my solution is to make a separated redirect button which will be hit after showing msg:
HTML:
<h:form prependId="false">
<p:growl />
<p:button outcome="gotoABC" id="rdr-btn" style="display: none;" />
<p:commandButton action="#{bean.process()}" update="@form" />
</form>
Bean:
public void process(){
addInfoMsg(summary, msgDetail); //Add msg func
RequestContext.getCurrentInstance().execute("setTimeout(function(){ $('#rdr-btn').click(); }, 3000);"); // 3 seconds delay. I put the script in Constants to config later.
}