I have a visualforce component, that takes in an attribute of account ID. Now this attribute in the component is assigned to a variable in the component's controller. In the constructor of the component's controller, I have put the value of this variable in system.debug and it is being shown as null.

But when I later invoke the same code by a button on the component which invokes a method in the component's controller - the value is shown correctly in the debug log. Hence concluded that in the component's controller constructor cannot obtain the value in the getter/setter field.

Is there any way to achieve this, i.e. obtain a value passed from the VF page into the VF component, in the constructor of the VF component? Thanks in advance


1 Answer 1


As Kurunve already indicated: this has to to with the order of execution for visualforce pages. First the constructor is executed and only after that the expressions in your component are executed.

See hereunder a chart of th Visualforce execution life cycle.

VisualForce Order of Execution chart


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.