Hello friends, In this tutorial, we are going to learn Action Poller function in Visualforce Pages Salesforce. Action Poller acts as a timer in visualforce pages. It is used to make an Ajax request to the server at a particular interval of time that you specify. Each request can result in a full or partial page update.
What is Action Poller Function in Visualforce Pages Salesforce:
Action Poller acts as a timer in visualforce pages. It is used to make an Ajax request to the server at a particular interval of time that you specify. Each request can result in a full or partial page update.
Syntax for declaring Action Poller function in Visualforce Pages Salesforce:
<apex:actionPoller action="{!actionmethod}" reRender="targetpanel" interval="10" enabled = “true” />
The attribute of Action Polar function.
The Action Poller function has the following attributes:
interval: The attribute specifies the time interval between Ajax requests in second. The minimum value for this attribute must be 5 seconds or greater if you do not specify any value for this attribute then the default value will be 60 seconds.
action: The action method invoked by the periodic AJAX update request from the component.
enabled: A Boolean value that specifies whether the poller is active. If not specified, this value defaults to true.
reRender: Comma separated id’s of one or more components that are refreshed when a request completes.
Example of Action Poller function:
In this example, action calls the method Counter at every 5 seconds. The variable iCounter is incremented by 5. Open the Developer Console and Create an Apex class called actionPollarController.
public class actionPollarController { public Integer iCounter{get;set;} public actionPollarController(){ iCounter = 0; } public void Counter(){ iCounter = iCounter + 5; } }
Create a Visualforce Page and write the following code.
<apex:page controller="actionPollarController" tabStyle="Account"> <apex:form > <apex:pageBlock id="myPageId"> <apex:pageBlockSection title="actionPoller Demo" collapsible="false" columns="1"> <apex:actionPoller action="{!Counter}" reRender="target" interval="5"/> <apex:outputText value="{!iCounter}" label="Timer:" id="target"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
View More:
- Action Function in Visualforce Page Salesforce.
- What is Profile in Salesforce?
- Custom Settings in Salesforce.
- Salesforce SOQL Queries Example
Conclusion:
I hope you would love this post. Please feel free to comment for any technical help. Your feedback and suggestions would be appreciated.
Thank You.
Fantastic post but I was wanting to know if you could write a litte more on this topic? I’d be very grateful if you could elaborate a little bit more. Cheers!|