AJAX - Ajaxify
p:ajax enables ajax behavior on any JSF component.
Source
<h:form id="form">
<p:panel header="Ajaxify">
<h:panelGrid columns="3" cellpadding="5">
<h:outputText value="KeyUp: " />
<p:inputText id="firstname" value="#{pprBean.firstname}">
<p:ajax event="keyup" update="out1" />
</p:inputText>
<h:outputText id="out1" value="#{pprBean.firstname}" />
<h:outputText value="Blur: " />
<p:inputText id="surname" value="#{pprBean.surname}">
<p:ajax event="blur" update="out2" />
</p:inputText>
<h:outputText id="out2" value="#{pprBean.surname}" />
</h:panelGrid>
</p:panel>
</h:form>
package org.primefaces.examples.view;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
public class PersonBean {
private String firstname;
private String surname;
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public void savePerson(ActionEvent actionEvent) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Welcome " + firstname + " " + surname + "!"));
}
}
