+ Start a Discussion
jcaldjcald 

add standard controller from a Custom controller

Is there a way to call out a standard controller for ex. "Account" from an already existing custom controller? What is the best practice for using a custom controller and standard controller together from one apex class. or is my thinking is all wrong? Thanks
Best Answer chosen by jcald
justin_sfdcjustin_sfdc
A Visualforce page can have only one controller (standard or custom) and as many extensions as you want.
so, if you need to utilize the standardController and have apex logic class and you would do the following:

<apex:page standardController="Account" extensions="myClass">
...
...
</apex:page>

Hope that solved your curiosity!

Thanks,
justin~sfdc

All Answers

Adnubis LLCAdnubis LLC
Why not just write an extension instead? Use a standard controller on your page and use the extension to add any additional logic you need. If you need any help with extensions let me know but that is the right way to go.
justin_sfdcjustin_sfdc
A Visualforce page can have only one controller (standard or custom) and as many extensions as you want.
so, if you need to utilize the standardController and have apex logic class and you would do the following:

<apex:page standardController="Account" extensions="myClass">
...
...
</apex:page>

Hope that solved your curiosity!

Thanks,
justin~sfdc
This was selected as the best answer
jcaldjcald
Thank you. This indeed solved my curiosity and i've started to use extensions.