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
Travis Malle 9Travis Malle 9 

Don't Run Methods unless called by Button

Hello Community,

I’m developing a single Visualforce page that displays Visualforce charts in a tabbed layout and need some help with the most efficient way to get my chart data. Currently, I am populating the chart data via GetMethods in my controller, I understand this is a poor design as all methods will run every time the page reloads. Also, my methods are loaded with database queries that makes for long load times.
 
In an ideal state, I would like to initially load the page without calling any method in the controller, then when a button is clicked, call the appropriate method and populate the chart data.
 
If someone could give me some advice on the most efficient way to accomplish it would be greatly appreciated.
 
Thank you,

User-added image
Hemant_SoniHemant_Soni
Hi Travis Malle,
Travis i think your code is executing in page initialize or you call your method in constructor that's why always your page is reload and call all method.You need to try conditional rendering which prevent your page reload.Conditional rendering reload particular area of page which you need to reload.

Hope this help you
If you need more help on this you can contact on 
soni.sonihemant.hemant@gmail.com
sales force 48sales force 48
Hi Travis Malle 9,

You can use a button to achieve this , once the button is clicked the init methods gets run.

Regards,
Srikanth