Toolbar is a grouping component for buttons and other content.
<div class="card">
<h:form>
<p:growl id="messages" showDetail="true"/>
<p:toolbar>
<p:toolbarGroup>
<p:commandButton type="button" value="New" icon="pi pi-file" styleClass="mr-2" />
<p:commandButton type="button" value="Open" icon="pi pi-folder-open" styleClass="ui-button-success" />
<i class="pi pi-bars px-2"/>
<p:commandButton type="button" title="Save" icon="pi pi-save" styleClass="ui-button-help mr-2" />
<p:commandButton type="button" title="Print" icon="pi pi-print" styleClass="ui-button-warning mr-2"/>
<p:commandButton type="button" title="Delete" icon="pi pi-trash" styleClass="ui-button-danger"/>
</p:toolbarGroup>
<p:toolbarGroup align="right">
<p:menuButton value="Options">
<p:menuitem value="Save" action="#{toolbarView.save}" update="messages" icon="pi pi-save"/>
<p:menuitem value="Update" action="#{toolbarView.update}" update="messages" icon="pi pi-refresh"/>
<p:menuitem value="Delete" action="#{toolbarView.delete}" ajax="false" icon="pi pi-times"/>
<p:menuitem value="Homepage" url="http://www.primefaces.org" icon="pi pi-home"/>
</p:menuButton>
</p:toolbarGroup>
</p:toolbar>
</h:form>
</div>
@Named
@RequestScoped
public class ToolbarView {
public void save() {
addMessage("Success", "Data saved");
}
public void update() {
addMessage("Success", "Data updated");
}
public void delete() {
addMessage("Success", "Data deleted");
}
public void addMessage(String summary, String detail) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary, detail);
FacesContext.getCurrentInstance().addMessage(null, message);
}
}