I have a visualforce component as below:
<apex:component controller="RecordDisplayController">
<apex:attribute name="objectName" description="An Sobject" type="Sobject" required="false" assignTo="{!objectvar}"/>
</apex:component>
RecordDisplayController:
public class RecordDisplayController {
public sObject objectvar{get;set;}
public RecordDisplayController.RecordDisplayController(){
system.debug('===========================>'+ objectvar); // it's null
}
}
My Visualforce page has:
<apex:page standardController="Account">
<c:recorddisplay objectName="{!Account}" />
</apex:page>
How to get the Account which I have mentioned in my VF page into the my controller associated with VF component? I used:
public RecordDisplayController.RecordDisplayController(ApexPages.StandardController stdController) {
this.objectvar = stdController.getRecord();
}
But this did not work. I know I have to assign a value to objectvar before using it but where can I do that since I do not call any method in VF component or VF page.