I am new to VisualForce and trying to understand the order of execution and came across this example in the page developer's guide where a sample page uses a custom component-
<apex:component controller="componentController1"> <apex:attribute name="value" type="String" description="Sample component." assignTo="{!selectedValue}"/> <p> Value = {!value}<br/> selectedValue = {!selectedValue}<br/> EditMode = {!EditMode} </p> </apex:component> The associated controller -
public class componentController1 { public String selectedValue {get; set { editMode = (value != null); // Side effect here - don't do this! selectedValue = value; } } public Boolean editMode {get;private set;} } It makes sense that the constructors on the associated controller should execute first after the constructors of the main page have been executed. In this case the implicit constructor is called so the initialised values of class variables after constructor is called would be
selectedValue = null editMode = null
Why the documentation says the following while further explaining the execution?
the value of EditMode is not yet known. EditMode is a boolean variable on the componentController. It is set based on the whether value is equal to null: set { selectedValue = value; // Side effect here - don't do this! editMode = (value != null); }
The associated component's implicit controller has already executed and the member variables selectedValue & editMode are set to null.Why the doc says the value of EditMode is not yet known? Also what is making the set accessor of selectedValue property to be called?