+ Start a Discussion
CraigHCraigH 

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.

 

 

bob_buzzardbob_buzzard

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.