RemoteCommand provides a simple way to execute backing bean methods with javascript.
Documentation<h:form> <p:remoteCommand name="rc" update="msgs" action="#{remoteCommandView.execute}" /> <p:growl id="msgs" showDetail="true" skipDetailIfEqualsSummary="true" /> <p:commandButton type="button" onclick="rc()" value="Execute" icon="pi pi-refresh" /> </h:form>
@Named @RequestScoped public class RemoteCommandView { public void execute() { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Executed", "Using RemoteCommand.")); } }