In this blog we are going to learn about <apex:actionPoller> in visualforce page. It sends the Ajax request to the server periodically according to  specified time interval . Let’s see an example, how it works.


Before going further let’s see some attributes of <apex:actionPoller> which we are going to use in the example.

  • action : The action method which is invoked by AJAX request periodically.
  • interval : Time interval between two ajax call. It must be greater than or equal to 5 sec. Default value is 60 sec .
  • reRender : Id of the component which should be updated after completion of AJAX request.

Note : For further attribute reference please go through Salesforce Documentation.


In this example we are going change the name of fruit in particular interval of time.

# Visualforce Page

<apex:page controller="exampleCon" sidebar="false">
        * Webkul Software.
        * @category Webkul
        * @author Webkul
        * @copyright Copyright (c) 2010-2016 Webkul Software Private Limited (
        * @license
    <apex:form >
        <apex:outputText value="Watch the changing fruit: {!count} : {!currentFruit}" id="counter"/>
        <apex:actionPoller action="{!incrementCounter}" reRender="counter" interval="6"/>

# Apex Class:


public class exampleCon {
        * Webkul Software.
        * @category Webkul
        * @author Webkul
        * @copyright Copyright (c) 2010-2016 Webkul Software Private Limited (
        * @license
    private List<String> fruitList = new List<String>();
    Integer count = 0;
    // Fruit name to be displayed
    public String currentFruit {
            currentFruit = fruitList[count];
            return currentFruit; 
    // Increment the counter value
    public PageReference incrementCounter() {
        if(count< 6) {
        } else {
            count = 0; 
        return null;
    public Integer getCount() {
        return count;
    // Constructor define the list of fruits
    public exampleCon () {


# Initially time = 0 sec.

# After 15 sec


That’s all for  <apex:actionPoller> in visualforce page, still if you have any further query  feel free to contact us, we will be happy to help you


Leave A Reply

Please verify that you are not a robot.

Tell us about Your Company

How can we help you with your business?

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home