Growl displays messages in an overlay.
<div class="card">
<h:form>
<p:growl id="growl" showDetail="true" />
<p:growl id="growl-sticky" for="sticky-key" showDetail="true" sticky="true" />
<h5 class="mt-0">Severities</h5>
<p:commandButton actionListener="#{growlView.showInfo}" update="growl" value="Info" styleClass="mr-2" style="width: 10rem" />
<p:commandButton actionListener="#{growlView.showWarn}" update="growl" value="Warn" styleClass="mr-2 ui-button-warning" style="width: 10rem" />
<p:commandButton actionListener="#{growlView.showError}" update="growl" value="Error" styleClass="ui-button-danger" style="width: 10rem" />
<h5>Multiple</h5>
<p:commandButton actionListener="#{growlView.showMultiple}" update="growl" value="Multiple" style="width: 10rem" styleClass="ui-button-outlined" />
<h5>Sticky</h5>
<p:commandButton actionListener="#{growlView.showSticky}" update="growl-sticky" value="Info" style="width: 10rem" styleClass="ui-button-help" />
</h:form>
</div>
package org.primefaces.showcase.view.message;
import jakarta.enterprise.context.RequestScoped;
import jakarta.faces.application.FacesMessage;
import jakarta.faces.context.FacesContext;
import jakarta.inject.Named;
import io.quarkus.runtime.annotations.RegisterForReflection;
@Named
@RequestScoped
@RegisterForReflection(serialization = true)
public class GrowlView {
public void addMessage(FacesMessage.Severity severity, String summary, String detail) {
FacesContext.getCurrentInstance().
addMessage(null, new FacesMessage(severity, summary, detail));
}
public void showInfo() {
addMessage(FacesMessage.SEVERITY_INFO, "Info Message", "Message Content");
}
public void showWarn() {
addMessage(FacesMessage.SEVERITY_WARN, "Warn Message", "Message Content");
}
public void showError() {
addMessage(FacesMessage.SEVERITY_ERROR, "Error Message", "Message Content");
}
public void showSticky() {
FacesContext.getCurrentInstance().addMessage("sticky-key", new FacesMessage(FacesMessage.SEVERITY_INFO, "Sticky Message", "Message Content"));
}
public void showMultiple() {
addMessage(FacesMessage.SEVERITY_INFO, "Message 1", "Message Content");
addMessage(FacesMessage.SEVERITY_INFO, "Message 2", "Message Content");
addMessage(FacesMessage.SEVERITY_INFO, "Message 3", "Message Content");
}
}