You need to sign in to do that
Don't have an account?
Arvind1
Calling interval of actionpoller from Controller
Hi,
I am calling a method from my controller every 5 seconds.
But I want to dynamically change the interval by adding a custom setting and calling the custom setting in apex class and
referring that in the interval attribute of actionpoller.
But when I tried that, the method is not getting called every 5 seconds. It is taking the default interval as 60 seconds.
I also tried by creating an Integer variable in the controller and called that in the interval attribute of actionpoller.
Following is my code which I am trying:
public class exampleCon { Integer count = 0; Integer interval=5; public PageReference incrementCounter() { count++; return null; } public Integer getinterval(){ return interval; } public Integer getCount() { return count; } }
<apex:page controller="exampleCon"> <apex:form > <apex:outputText value="Watch this counter: {!count}" id="counter"/> <apex:actionPoller action="{!incrementCounter}" rerender="counter" interval="{!interval}"/> </apex:form> </apex:page>
Please let me know any suggestions.
Thanks
Arvind
I have the exact same issue. Does anyone know a solution to this?
I am also getting the same problem? Any one have a alternate solution for this ?
I am seeing the same issue. Has anyone found a solution as it would be of great help to me?
In a nutshell create 2 actionPollers with different "rendered" variables. In the controller, instead of passing the variable to the "Interval" parameter, set your boolean for "render" parameter.
Like Such...
VF Page:
<apex:actionPoller action="{!reload}" rerender="mainform" interval="5" rendered="{!render120}"/>
<apex:actionPoller action="{!reload}" rerender="mainform" interval="10" rendered="{!render600}"/>
Class:
//declare variables
public boolean render120 {get;set;}
public boolean render600 {get;set;}
then in the constructor:
//set refreshTime boolean variables
if('x'=='x'){ // set needed conditions here
render120 = true;
render600 = false;
}
else{
render120 = false;
render600 = true;
}
* make sure you dont have multiple "true" variables
I know this is not pretty, but it worked for my basic requirement.