PrimeFaces Beginner's Guide
上QQ阅读APP看书,第一时间看更新

Time for action – displaying FacesMessages with growl

We will see how to display FacesMessages with different severity levels as Growl notifications using <p:growl>. Perform the following steps:

  1. Create a JSF page with a form and growl component:
    <p:growl id="growl1" autoUpdate="true" severity="info,warn,error, fatal" sticky="true" globalOnly="true"/>
    <h:form>
      <p:commandButton actionListener="#{messagesController.addMultipleMsgs}" value="Add Multiple Messages"/>
    </h:form>

What just happened?

When the button is clicked, we have added FacesMessages. The growl component gets updated automatically and displayed notifications because we have set autoUpdate mode to true.