You need to sign in to do that
Don't have an account?
Kumar Rao 1
Why is Constructor in a Controller
Dear Folks,
I'm very new to Salesforce and VisualForce (of course Programming), Can some one please educate me:
1. Why Constrcutor is required for a VisualForce Page?
2. What is the actual need of this?
3. What would happen If a constructor is not used inthe Controller?
Here is a sample code.. I understood the logic but I don't understand wht we need AcExt Constructor?
Public with sharing class AcExt {
Public Account ac;
Public AcExt(ApexPages.StandardController stdctrl){
ac = (Account)stdctrl.getRecord();
}
Public string GetGreeting(){
return 'Your ID is ' +ac.id;
}
}
Thanks,
Kumar
I'm very new to Salesforce and VisualForce (of course Programming), Can some one please educate me:
1. Why Constrcutor is required for a VisualForce Page?
2. What is the actual need of this?
3. What would happen If a constructor is not used inthe Controller?
Here is a sample code.. I understood the logic but I don't understand wht we need AcExt Constructor?
Public with sharing class AcExt {
Public Account ac;
Public AcExt(ApexPages.StandardController stdctrl){
ac = (Account)stdctrl.getRecord();
}
Public string GetGreeting(){
return 'Your ID is ' +ac.id;
}
}
Thanks,
Kumar
The controller is a class. The constructor tells us how to create an instance of that class, and the VF page uses that instance to know what information to display.