Javatpoint Logo
Javatpoint Logo

component in Visualforce Page

The <apex:actionPoller> component is a special type of component that works based on time and interval. It is a timer used for sending an AJAX request to the server according to the specified time interval.

The <apex:actionPoller> component should be used within the region it acts upon. If we want to use the <apex:actionPoller> with the <apex: actionRegion>, the <apex:actionPoller> should be used within the <apex:actionRegion> component.

In order to use the <apex:actionPoller> component, we have to go through the following consideration:

  1. The action method should be light-weighted, which we define in the <apex:actionPoller>. In the action method, we need to avoid using DML, external service calls, and other resource-intensive operations.
  2. The connection is regularly refreshed by the <apex:actionPoller> component, so we must keep the login session alive. Due to inactivity, the apex page with the <apex:actionPoller> would not timeout.
  3. It resets itself when the <apex:actionPoller> component is ever re-rendered as the result of another action.
  4. For defining the time interval to server requests from the apex controller, we can't use the Visualforce expression.
  5. We need to avoid using actionPoller with enhanced lists.

The <apex:actionPoller> component has the following attributes:

1. action

The action attribute is of type ApexPages.Action that defines the action method. The action method is invoked by the periodic AJAX update request from the component. The page simply refreshes when there is no action method defined in this component.

Syntax

2. enabled

The enabled attribute is of type Boolean that is used to specify the active and inactiveness of the <apex:actionPoller> component. By default, its value is set to true.

Syntax

3. id

The id attribute is of type string that is a unique identifier allowing this component to be referenced by other components on the page.

Syntax

4. interval

The interval attribute is of type Integer that is used to specify the time interval between AJAX update requests in seconds. The value of this attribute must be 5 seconds or greater. By default, its value is set to 60 seconds.

Syntax

5. oncomplete

The oncomplete attribute is used to specify the JavaScript method invoked when the result of an AJAX update request completes on the client.

Syntax

6. onsubmit

The onsubmit attribute is used to specify the JavaScript method invoked before sending an AJAX update request to the server.

Syntax

7. rendered

The rendered attribute is of type Boolean that is used to specify whether the current component is rendered on the page or not. By default, its value is set to true.

Syntax

8. reRender

When we want to redraw one or more components on the page after receiving the result of an AJAX update request by the client, we use this component to specify the Ids of those components.

Syntax

9. status

The status attribute is of type string that is used for specifying the id of the component responsible for displaying the status of an AJAX update request.

Syntax

10. timeout

The timeout attribute is used for defining the amount of time before an AJAX update request should timeout.

Syntax

Let's take an example to understand how we can use the <apex:actionPoller> component in VF:

ApexActionPollerExample.vfp

ApexActionPollerController.apxc

Output

apex:actionPoller component in Visualforce Page
Next Topic#





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA