actionPoller visualforce salesforce

actionPoller visualforce salesforce

Actionpoller acts as a timer in visuaflorce page. It is used to send an AJAX request to the server depending on the timeinterval that we specify in interval attribute (time interval has to be specified or else it defaults to 60 seconds).Each request can result in a full or partial page update.

<apex:actionPoller> has following important attributes:

  • interval: The time interval between AJAX update requests, in seconds. This value must be 5 seconds or greater, and if not specified, defaults to 60 seconds
  • action: The action method invoked by the periodic AJAX update request from the component.
  • reRender: Comma separated id’s of one or more components that are refreshed when request completes.

In the example below, action poller calls the method “callMethod” every 10 seconds. In callMethod, the variable “seconds” counter is incremented by 10. Rerender attribute refreshes the outputText, so seconds value in page will be refreshed.

Click for Demo

Visualforce Code:

<apex:page controller="actionpollerDemoController" tabStyle="Account">
    <apex:form >
        <apex:pageBlock id="myPageId">
            <apex:pageBlockSection title="actionPoller example" collapsible="false" columns="1">
              <apex:actionPoller action="{!callMethod}" reRender="out" interval="10"/>
              <apex:outputText value="{!seconds}" label="Time in seconds since action poller is called:" id="out"/>

Apex Code:

public class actionpollerDemoController {
public  Integer seconds{get;set;}
  public actionpollerDemoController(){
   seconds = 0;

  public void callMethod(){
    seconds = seconds + 10;

Permanent link to this article:

1 comment

    • Venkatesan on June 3, 2022 at 8:23 pm
    • Reply

    Love this demonstration 🙂

Leave a Reply

Your email address will not be published.