Tuesday, December 6, 2016

Visualforce - Beyond Basics Series 4 - actionpoller is your timer

How to perform timed action ?

if you need to fire action method calls (ajax calls to server) periodically, just like a timer, you need to use actionPoller tag. This will call the action methods at regular intervels & rerender the section of the screen(optionally).

Where is the code ?

The actionpoller tag can be illustration with following example. This updates the userRetries count everytime it sends the request to server. Finally, when it reached 10 times, it quits.


Precautions ?

you need to keep following things in mind, before using this tag

  •   Since, this calls repeatedly by itself & can run very silently in browser, it should be used only if it's required.
  •   One advantage of using this method is that it keeps the session alive & user login cannot timeout.
  •   The best practice is to avoid heavy DML, Call out, Trigger logic through it.



No comments:

Post a Comment

Thanks for reading my blog !