You need to sign in to do that
Don't have an account?
charlie_v
List of Contacts for current page's Account id
Using a custom controller, I am selecting id, name, etc from Account where id = current page's accountid. That seems to be working fine.
Next, I need to list all of the Contacts for the account in a drop-down list on my Apex page. Once a user selects a Contact, I need to capture and store the contactid.
This is the error message I keep getting: Compile Error: Constructor not defined: [System.SelectOption].<Constructor>(Id) at line 18 column 29
Here's my class code. What am I doing wrong? I lifted this from an example shown at http://forums.sforce.com/sforce/board/message?board.id=Visualforce&message.id=2344.
Next, I need to list all of the Contacts for the account in a drop-down list on my Apex page. Once a user selects a Contact, I need to capture and store the contactid.
This is the error message I keep getting: Compile Error: Constructor not defined: [System.SelectOption].<Constructor>(Id) at line 18 column 29
Here's my class code. What am I doing wrong? I lifted this from an example shown at http://forums.sforce.com/sforce/board/message?board.id=Visualforce&message.id=2344.
Code:
public class comboOppController { public Account getAccount() { return [select id, Name, Phone from Account where id = :ApexPages.currentPage().getParameters().get('id')]; } public String selectedContact {get;set;} public List<SelectOption> contactList; public List<SelectOption> getContact () { if (contactList == null) { List<Contact> contactee = [select id, name, contact.accountid from Contact where contact.accountid = :ApexPages.currentPage().getParameters().get('id')]; contactList = new List<SelectOption>(); for (Contact c : contactee) { contactList.add(new SelectOption(c.id)); } } return contactList; } }
example
options.add(new SelectOption('US','US'));
options.add(new SelectOption('CANADA','Canada'));
options.add(new SelectOption('MEXICO','Mexico'));
the first one is the value , the second is the label shown in the picklist
Error: javax.el.ELException: Cannot coerce from class core.apexpages.el.adapters.metadata.SObjectMetadataELAdapter to interface common.apex.SObjectRow
Error: Cannot coerce from class core.apexpages.el.adapters.metadata.SObjectMetadataELAdapter to interface common.apex.SObjectRow
I changed that line of code to:
are you in the browser or Eclipse?
i did this in the browser.
here is my complete src, see if you can save this in a fresh class
Message Edited by Ron Hess on 08-07-2008 09:44 AM
Anyway, thanks Ron. I really appreciate your help!
check that all the classes in your org are valid, you may have to re-compile some of them as dependent classes are modified.
you also get the award for longest object name in an error message that i've seen in a while...