Johnny2012
Johnny2012

Reputation: 1532

How to set growl life programmatically in JSF (Primefaces)?

Is it possible to set the growl life duration programmatically in my Bean?

Upvotes: 2

Views: 5779

Answers (2)

kolossus
kolossus

Reputation: 20691

You can either

  1. Bind the client-side growl component to a server-side instance of the same component

    Growl growl = new Growl(); //Growl is from org.primefaces.component.growl.
    growl.setLife(6000);
    //getter & setter
    

    and in your view:

    <p:growl binding="#{myBean.growl}" autoUpdate="true" globalOnly="true" id="theGrowl" widgetVar="aGrowl"/>
    
  2. Or use the following javascript call (by way of the RequestContext if you prefer)

       aGrowl.setRemovalTimeout(600);
    

    Where aGrowl is the widgetVar value you would've configured on your <p:growl/> component in your JSF view

Upvotes: 7

nfechner
nfechner

Reputation: 17525

The Growl class provides a setter for the life property: Growl#setLife(int)

Upvotes: 0

Related Questions