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>
package org.primefaces.showcase.view.ajax;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Named;
import java.io.Serializable;
import io.quarkus.runtime.annotations.RegisterForReflection;
@Named
@ViewScoped
@RegisterForReflection(serialization = true)
public class PollView implements Serializable {
private int number;
public void increment() {
number++;
}
public int getNumber() {
return number;
}
}