Action Poller in Visualfoce Page

According to SF documentation, It is

A timer that sends an AJAX request to the server according to a time interval that you specify. Each request can result in a full or partial page update.

Examples :

  1. After certain amount of time, you want to perform specific event.
  2. From Apex if you want to get continuous status of batch and then you want to execute specific task.
  3. If you want to split transactions for doing multiple activities.

Document from salesforce is here.

Let’s understand this by below example.

We will print the Booking Status. This sample page will poll the server for getting current status while displaying the specific message “Booking Your Tickets…” when action poller executes.

When the status changed to Booked we want to terminate the action poller.

Live demo available here.

Apex Class :

Visualforce Page :