actionPoller
What is actionPoller tag? This tag specifies a timer that sends an AJAX update request at specified interval. Minimum interval time to refresh is 5 sec.
Here in this post i am providing a simple example to explain about actionPoller. I am calling a simple method from controller to display Date & TIme and recalling that method by using actionPoller tag to change the time for every 5 sesc. See the below code to understand how actionPoller will work.
Visualforce page Code:
<apex:page controller="actionpollerDemoController"> <apex:form > <apex:pageBlock id="pb"> <span style="color: #ff0000;" data-mce-style="color: #ff0000;"><strong><apex:actionPoller action="{!dateTimeMethod}" reRender="pb" interval="5"/></strong></span> Hello!!! Date and Time: <strong><span style="color: #ff0000;" data-mce-style="color: #ff0000;">{!dateAndTime}</span> </strong> <p>Note: Time will refresh fror eevry 5 sec.</p> </apex:pageBlock> </apex:form> </apex:page>
Apex Controller:
public with sharing class actionpollerDemoController { public DateTime dateAndTime{ get; set; } public void dateTimeMethod(){ dateAndTime = System.now(); } }
OutPut: In below screen rounded part will refresh for every 5 secs