+ Start a Discussion
gv007gv007 

Visualforce Error Invalid selectOptions found. Use SelectOption type in Apex.

i am trying to display list valus from an object using an listbox option am getting the following error here it the code .I missed some thing?I missed some thing in the code.

 

VF page

 

 

<apex:page controller="ABC">

<apex:selectList id="topq" value="{!top}" required="true" multiselect="false" title="Select " size="4"> <apex:selectOption value="{!pop}" />

</apex:selectList>

</apex:page>

 

 

 

 

 

controller:

 

 

 

 

 

 

value="{!top}" have it own get and seter.

 

 

 

 

List<CustomObject__c> pop;

public List<CustomObject__c> getpop() { if(pop== null) pop= [select customfield__c from CustomObject__c limit 100]; return pop; }

 

 

Message Edited by gv007 on 05-08-2009 09:32 AM
Message Edited by gv007 on 05-08-2009 09:33 AM
SaaspertSaaspert

you are trying to set value selected from drop down to top hence you would need a public property in controller

 

public <object_type> top {get; set;}

 

also if pop is a list then use apex : selectoptions (plural)

 

 check details in visualforce guide 

gv007gv007

I already tested that ,my geter,seter are public only.

NikhilNikhil

Hi

 

You are binding the <apex:SelectOption> directly with sObject List

rather doing this do it like this way

 

 

 

public List<SelectOption> getpop()

{

 

pop = [select customfield__c from CustomObject__c limit 100];

if (pop.Size() >0)
{
for(CustomObject__c c:pop)

{
if (c.customfield__c != null)
options.add(new SelectOption(c.customfield__c,c.customfield__c));
}
}

return options;

}

 

 

 

 

 

I hope you got the feel of what i am trying to explain you

 

:)

 

NikhilNikhil

I missed one more line of code

 

Please add this in function

 

List<SelectOption> options = new List<SelectOption>();

 

gv007gv007
Thanks Nikil ,i already did it due to weekend i did't posted the solution .thanks for posting yours code also I will improve some test coverage and post on forum it is a common need to any developer.