6

Can we stop the <apex:actionPoller> from executing after a set duration?

0
10

You can tweak the example from the docs just slightly to check an isEnabled property.

Controller

public with sharing class Demo
{
    final Long start = Datetime.now().getTime();
    public Boolean getIsEnabled() { return Datetime.now().getTime() - start < 60 * 1000; }

    Integer count = 0;
    public Integer getCount() { return count; }
    public PageReference incrementCounter() {
        count++;
        return null;
    }
}

Page

<apex:page controller="Demo">
    <apex:form>
        <apex:outputText value="Watch this counter: {!count}" id="counter"/>
        <apex:actionPoller action="{!incrementCounter}" reRender="counter" interval="5" enabled="{!isEnabled}"/>
    </apex:form>
</apex:page>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.