AJAX - Counter
An integer variable(count) in counterBean is incremented each time the button is clicked.
An integer variable(count) in counterBean is incremented each time the button is clicked.
<h:form>
<h:panelGrid columns="2" cellpadding="5">
<h:outputText value="Counter: " />
<h:outputText id="txt_count" value="#{counterBean.count}" />
</h:panelGrid>
<p:commandButton value="Count"
actionListener="#{counterBean.increment}" update="txt_count"/>
</h:form>
package org.primefaces.examples.view;
import java.io.Serializable;
public class CounterBean implements Serializable{
private int count;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public void increment() {
count++;
}
}
Running PrimeFaces-4.0-SNAPSHOT on Mojarra-2.1.22
