You need to sign in to do that
Don't have an account?
Creating an Apex controller extension that allows for multiple standard controllers in a VF page
Hello,
I'm trying to create an Apex controller extension that allows me to use more than one Standard controller in a VF page. Right now, I'm creating a Document Request Form for my organization, but one of the steps requires me to retrieve fields from Contacts, Opportunities, and Accounts. I was wondering if there was a way to write an extension to incorporate the functions of these standard controllers into one controller?
I tried doing this, while still using the Opportunity standard controller in my VF page, and this class as an extension, but it didn't work the way I thought it would:
private final Opportunity opp; private final Contact cont; public ApexPages.StandardController stdCtrl; public drfExtension(ApexPages.StandardController std) { stdCtrl = std; this.opp = (Opportunity)std.getRecord(); this.cont = (Contact)std.getRecord(); }
Quick and dirty method if you have a limited number of sObjects you're testing for - you can use getDescribe...?
Like I said - quick and DIRTY, but it should work for ya.
-Andy
It didn't work. I thought it did at first, but that was only for the page that was dealing strictly with Opportunities. For the Contact and Account pages, I get the errors "Unknown property 'OpportunityStandardController.contact'" and "Unknown property 'OpportunityStandardController.account'"