How would I go about triggering a apex controller method every certain period of time?

This is the general idea I need to implement: "Autosave information every 5 minutes on a visual force page". I already have a save function written in my apex controller, which I used for save buttons.

Thank you for your time!


You can use <apex:actionPoller/> to implement your requirement


<apex:page controller="autoSaveController"> 
<apex:form id="form1">
<apex:actionPoller action="{!save}" rerender="form1" interval="300"/>
<apex:commandButton value="save" action="{!save}"/>

In the save() method in the controller class you can hold page values in the List, Map or any other suitable ways and finally call commit if necessary.

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.