function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Controller calling action after the page has loaded

Is there a way to have a VF page call a controller method after the page loads (i.e. similar in concept to the action attribute only that it executes after the page has displayed).


i.e. if the controller method takes a while to run, I'd like to have something show on the VF page indicating to please wait while the code is running.




I'm not aware of any visualforce markup that would allow this to happen.  The way that I'd approach this is to have some javascript that executes an actionfunction that in turn invokes the controller method.  


You could do this via an onload handler so that as soon as the page is loaded it gets invoked.  I'd also suggest that this is conditional based on a controller property, so that it doesn't fire again if the page contains a form that is submitted causing a refresh.