Order of execution in Visualforce page

1. Constructor of the controller.

2. Action method of the page.

3. Getter methods.

Sample Code:

Visualforce page:

<apex:page controller="Sample" action="{!sav}">
    <apex:outputText >{!mem}</apex:outputText>
</apex:page>

Apex Controller:

public with sharing class Sample {

    public String mem {
       get { return 'getter';}  
       set;
    }

    public sample() {
        mem = 'constructor';
    }
    
    public void sav() {
        mem = 'action';
    }    
}

Output:


Cheers!!!

No comments:

Post a Comment