function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ashok S 7Ashok S 7 

How to do the action poller component in vf page

Hai,
I want try actionpoller component in vf page but it is not working 
vf page code
<apex:page controller="ActionPollar_Controller" showHeader="true" tabStyle="case" sidebar="false">
<apex:form >
<apex:pageBlock >
<h1>Company Details</h1>
<apex:pageBlockTable id="compde" value="{!compdetails}" var="i">
<apex:column headerValue="Name"/>
<apex:outputLink value="/{!i.id}">{!i.Name}</apex:outputLink>

</apex:pageBlockTable>
</apex:pageBlock>
<apex:actionPoller action="{!pollAction}" reRender="compde" interval="10"/>
</apex:form>
</apex:page>
controller
-----------------

public class ActionPollar_Controller 
{

    public Account[] getCompdetails() {
         compdetails = Database.query(query);
        return compdetails;
    
    }

    Account[] compdetails;
    string query = 'select id,name from  Account limit 15';
    
    public pagereference pollAction()
    {
        compdetails = Database.query(query);
        return null;
    
    }

}

how can i do .please help me
Best Answer chosen by Ashok S 7
Muthuraj TMuthuraj T
<apex:page controller="ActionPollar_Controller" showHeader="true" tabStyle="case" sidebar="false">
    <apex:form >
        <apex:pageBlock >
           <h1>Company Details</h1>
           <apex:pageBlockTable id="compde" value="{!compdetails}" var="i">
                 <apex:column headerValue="Name" >
                       <apex:outputLink value="/{!i.id}">{!i.Name}</apex:outputLink>
                 </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
        <apex:actionPoller action="{!pollAction}" reRender="compde" interval="10"/>
     </apex:form>
</apex:page>

Hi,

The above code should work for you. I did some changes in VF page.

Please think throgh the logic. Since you are using action pllaer, it queries the object every 10 secs.

All Answers

Vishal_GuptaVishal_Gupta
Hi Ashok,

What is your requirment and what issue you are facing?
 
Muthuraj TMuthuraj T
<apex:page controller="ActionPollar_Controller" showHeader="true" tabStyle="case" sidebar="false">
    <apex:form >
        <apex:pageBlock >
           <h1>Company Details</h1>
           <apex:pageBlockTable id="compde" value="{!compdetails}" var="i">
                 <apex:column headerValue="Name" >
                       <apex:outputLink value="/{!i.id}">{!i.Name}</apex:outputLink>
                 </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
        <apex:actionPoller action="{!pollAction}" reRender="compde" interval="10"/>
     </apex:form>
</apex:page>

Hi,

The above code should work for you. I did some changes in VF page.

Please think throgh the logic. Since you are using action pllaer, it queries the object every 10 secs.
This was selected as the best answer