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
KHouseknechtKHouseknecht 

Problem setting ActionPoller Interval attribute from controller

I'm trying to set the Interval attribute of the ActionPoller component from a property in the underlying controller.  When I check the generated HTML, I see it defaults to 60,000ms, which is the default value if you don't specify a value for Interval.  If I hard code a value, say 5 secs, in the ActionPoller, then I see the correct 5,000ms in the generated HTML.  Here is the VF and Apex sample that demonstrates the faulty behavior:

 

<apex:page controller="PollerTestController" > 
<apex:form > 
    <apex:actionpoller interval="{!RefreshInterval}" action="{!testAction}" rerender="counter" /> 
    <apex:outputtext value="{!Count}" id="counter" />
    <br/>
    Interval: <apex:outputtext value="{!RefreshInterval}" />
</apex:form> 
</apex:page>

 

public class PollerTestController 
{
    
    integer m_count = 0; 
    
    public integer RefreshInterval
    {
        get{return 5;}
        set;
    }
    
    public void testAction() 
    { 
        m_count++; 
    } 
    
    public integer Count {get{return m_count;}}
    
}

 The generated JavaScript showing the default 60,000ms pollinterval value:

 

<script type="text/javascript">
A4J.AJAX.Poll('j_id0:j_id1',{'pollId':'j_id0:j_id1:j_id2','similarityGroupingId':'j_id0:j_id1:j_id2','parameters':{'j_id0:j_id1:j_id2':'j_id0:j_id1:j_id2'} ,'pollinterval':60000} );
</script>

 

If I change the ActionPoller to:

 

<apex:actionpoller interval="5" action="{!testAction}" rerender="counter" /> 

 Then I get:

 

<script type="text/javascript">
A4J.AJAX.Poll('j_id0:j_id1',{'pollId':'j_id0:j_id1:j_id2','similarityGroupingId':'j_id0:j_id1:j_id2','parameters':{'j_id0:j_id1:j_id2':'j_id0:j_id1:j_id2'} ,'pollinterval':5000} );
</script>

 Why is the ActionPoller seemingly ignoring the value coming from the property? 

 

NOTE:  I've already tried getter/setter methods instead of the property syntax, at the request of Salesforce Developer Support, since he told me that Apex uses getter/setter and doesn't have property syntax.  Really?  How long have I been writing Apex code? :)   And that doesn't work either.

 

 

 

Vinita_SFDCVinita_SFDC

Hi,

 

Can you print the vaue of 'RefreshInterval' using debug statements?

KHouseknechtKHouseknecht

Look at the code and even try it for yourself.  RefreshInterval is echoed out in an outputtext.  It shows the value of 5 right on the screen.

 

Also, look at the generated JavaScript that I have captured and posted.  It shows where the refresh interval is being applied and where its not.

 

I've also made the property a string isntead of an integer.  Same results.

Vinita_SFDCVinita_SFDC

Hi,

 

Seems it is working as per design reason being it is not catching value from controller and that is why it is taking default value of 60 seconds, not sure with the reason why has been designed so.

KHouseknechtKHouseknecht

I would say it certainly isn't working as one might expect.  Not sure at all if it's working as designed.  I was hoping to get some official confirmation one way or the other.

 

To me, this looks like a defect or an oversight.

GaryAGaryA
Has anyone come up with a solution for this?  I am having the same issue with dynamically setting the Interval attribute using controller variables.  This seems to either be a huge bug that has never been addressed or a very poor design choice.