Using action functions

An action function allows an action method from a controller to be executed from JavaScript. The standard Visualforce <apex:actionFunction /> component generates a named function that can be called from any JavaScript code.

In this recipe, we will create a Visualforce page that displays a list of cases and a countdown timer implemented in JavaScript. Once the timer expires, an action method from the page's controller is executed, which redirects the user's browser to the standard case tab.

Getting ready

This recipe makes use of a custom controller, so this must be created before the Visualforce page.

How to do it...

  1. Navigate to the Apex Classes setup page by clicking on Your Name | Setup | Develop | Apex Classes.
  2. Click on the ...

Get Visualforce Development Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.