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 :
- n
- After certain amount of time, you want to perform specific event.
- From Apex if you want to get continuous status of batch and then you want to execute specific task.
- If you want to split transactions for doing multiple activities.
n
n
n
Document from salesforce is here.
n
Let’s understand this by below example.
n
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.
n
When the status changed to Booked we want to terminate the action poller.
n
Live demo available here.
n
Apex Class :
public with sharing class BookingPollerContrl { // the payment statuses n public List < String > statuses = new List < String > {n 'Connecting to IRCTC',n 'Authorising',n 'Authorised',n 'Booked'n };n // the index of the current Status n private Integer currentStatusIdx = 0; // getter to retrieve the current Status n public String getBookingStatus() {n return statuses[currentStatusIdx];n }n // action method invoked by the poller - increments the n // current Status index n public PageReference changeBookingStatus() {n currentStatusIdx++;n return null;n }n}n
Visualforce Page :
n n n n n n n The status of your Booking is : n n n
n
n n n n n
#apex #Visualforce