
I have a list of Opportunities in a visualforce page populated from a SOQL query in a wrapper class
public List<SelectOption> getnewOpportunityList(){
List<SelectOption> newOpportunityList = new List<SelectOption>();
newOpportunityList.add(new SelectOption( ' ' ,'---Select---'));
newOpportunities = [Select o.Id, o.Name From Opportunity o WHERE o.AccountId = :this.parentAccount.Id ORDER BY o.Name];
for(Opportunity temp : newOpportunities)
{
newOpportunityList.add(new SelectOption(temp.Id, temp.Name));
}
System.debug('Selected Opportunity:'+newOpportunity);
return newOpportunityList;
}
and this is the page that displays the list ok:
<apex:column >
<apex:facet name="header">New Opportunity</apex:facet>
<apex:selectList size="1" title="New Opportunity" value="{!o.newOpportunity}">
<apex:actionSupport event="onchange" rerender="displayView2"/>
<apex:selectOptions value="{!o.newOpportunityList}"/>
</apex:selectList>
</apex:column>
however, when I select an opportunity from the list, it's not updating the newOpportunity field, I'm guessing I'm either missing
something or it's not possible to use SObjects in a list like this using the SelectOption?
Any help gratefully appreciated
David
5 respuestas
Unfortunately, no. You can make a lookup filter on a lookup field, but it works more like a validation - you get an error when you pick something "wrong". You'd have to go down the road of creating your own Visualforce lookup functionality if you want to do that.