Poll component makes remote calls periodically.
<div class="card">
<h:form>
<h1 class="text-center">
<h:outputText id="txt_count" value="#{pollView.number}"/>
</h1>
<p:poll interval="2" listener="#{pollView.increment}" update="txt_count" onactivated="console.log('Poll started')"/>
</h:form>
</div>
@Named
@ViewScoped
public class PollView implements Serializable {
private int number;
public void increment() {
number++;
}
public int getNumber() {
return number;
}
}