PrimeFaces Growl

Primefaces Growl with primefaces tutorial, primefaces introduction, primefaces features, primefaces configuration, ajax, event, listener, actionlistener, ajax process, ui component, autocomplete, inputtextarea, boolean button, boolean checkbox, calendar, inputtext, inputmask, select one list box, select many box, select checkbox etc

PrimeFaces Growl

PrimeFaces Growl

It is a notification widget which is used to display FacesMessages. It is similar to standard h:messages component of JSF. We can place growl to anywhere in our application's web page. The location of growl in JSF application does not matter.

By default it displays for 6000 ms after that hides. We can stick it by setting true. It has various other attributes that are tabled below.

Growl Attributes

Attribute Default value Type Description
sticky false Boolean It is used to specify that the message should stay instead of hidden automatically.
showSummary true Boolean It is used to show summery of the message.
showDetail false Boolean It is used to show detail of message.
globalOnly false Boolean It is used to set globally.
life 6000 Integer It is used to set display time of the message.
autoUpdate false Boolean It is used to set auto update mode.
redisplay true Boolean It is used to redisplay message.
for null String It is used to set name of associated key.
escape true Boolean It defines whether html would be escaped or not.
severity null String It is a comma separated list of severities to display only.


Here, in the following example, we are implementing <p:growl> component. This example contains the following files.

JSF File

// growl.xhtml

  1. <?xml version='1.0' encoding='UTF-8' ?>  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""">  
  3. <html xmlns=""  
  4. xmlns:h=""  
  5. xmlns:p="">  
  6. <h:head>  
  7. <title>Growl Messages</title>  
  8. </h:head>  
  9. <h:body>  
  10. <h:form>  
  11. <p:growl id="growl" showDetail="true" sticky="true" />  
  12. <p:panel header="User Login">  
  13. <h:panelGrid columns="2" cellpadding="5">  
  14. <p:outputLabel for="username" value="User Name: " />  
  15. <p:inputText id="username" value="#{growl.username}" required="true" />  
  16. </h:panelGrid>  
  17. <h:panelGrid columns="2" cellpadding="5">  
  18. <p:outputLabel for="password" value="Password: " />  
  19. <p:password id="password" value="#{growl.password}" required="true" />  
  20. </h:panelGrid>  
  21. <p:commandButton value="login" actionListener="#{growl.displayMessage}" update="growl" />  
  22. </p:panel>  
  23. </h:form>  
  24. </h:body>  
  25. </html>  



  1. package com.tpoint;  
  2. import javax.faces.application.FacesMessage;  
  3. import javax.faces.bean.ManagedBean;  
  4. import javax.faces.context.FacesContext;  
  5. @ManagedBean  
  6. public class Growl {  
  7. private String username;  
  8. private String password;  
  9. public String getUsername() {  
  10. return username;  
  11. }  
  12. public void setUsername(String username) {  
  13. this.username = username;  
  14. }  
  15. public String getPassword() {  
  16. return password;  
  17. }  
  18. public void setPassword(String password) {  
  19. this.password = password;  
  20. }  
  21. public void displayMessage() {  
  22. FacesContext context = FacesContext.getCurrentInstance();  
  23. context.addMessage(nullnew FacesMessage("Login Successfuly""Welcome: " + username));  
  24. }  
  25. }