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
Sujan Kumar ReddySujan Kumar Reddy 

Order of execution of Getter and Setter values

Hello,

 

Let say i have one visual force page with Constructor, Getter and Setter methods, What is the order of execution of these methods, it is an interview question which i faced..

 

Regards,

Sujan

Best Answer chosen by Admin (Salesforce Developers) 
salesforce1#salesforce1#

Hi sujan,

 

Setter is fires first, an then getter fires.

 

Setter is call before the action methods, the action method execute will be access the variable that was set.

 

Regards.

All Answers

PremanathPremanath

I think First vf page will executes i.e first line only

<apex:page controller="exampletest">

 

Then controller calls 

 

In that controller Constructor will fire automatically

 

Then any methods will fire ..

 

It may hlpful to you

salesforce1#salesforce1#

Hi sujan,

 

Setter is fires first, an then getter fires.

 

Setter is call before the action methods, the action method execute will be access the variable that was set.

 

Regards.

This was selected as the best answer
Sujan Kumar ReddySujan Kumar Reddy

Thank you!!

Satya Prakash 11Satya Prakash 11
I think below is the correct order of execution.
1. Checks for the Standard Controller in the page.
2. If it is not present, checks for Custom Controller and executes the class and calls Constructor.
3. Invokes action method attribute in the <apex:page> component.
4. Finally calls Getter and Setter methods.

Hope this helps!