You need to sign in to do that
Don't have an account?
Sane
How to get a property in contructor
Hi ,
Can I get property into my contructor ?
For example if I have a private list of Contacts and can I use getter methods into my contructor ?
The code below does not work
public class ExtContact {
private list<contact> lstcontact;
public ExtContact(ApexPages.StandardController controller) {
public list<contact> getlstcontact(){
lstcontact=[select id,firstName,lastName from contact LIMIT 10];
return lstcontact;
}
}
}
Please suggest,
Regards,
Sane
--
Thanks
Usman
All Answers
Yes Sane,
You can get please follow the code give below.
If you have still issue please let me know otherwise mark as complete.
--
Thanks
Usman
Thanks MoUsman,
May I please know what does the code inside contustor actually do ? I mean you are simply assigning the getter method for the contact to the variable.
How would be the execution order ? My understanding is whenever the class gets exectuted - Constructors are invoked. when actually these getter methods are invocked ?
Please Suggest,
Thanks in advance.
Regards,
Sane
--
Thanks
Usman