You need to sign in to do that
Don't have an account?
eriktown
Dropdown list options not working - "invalid selectOptions found"
Hey folks,
I'm a bit perplexed - I'm just trying to generate a simple list of options for a dropdown box, but when I try to load the page I get told "invalid selectOptions found". I've done this before and I'm pretty sure I'm doing it right -- if anyone can spot what I am doing wrong I'd appreciate it.
The VisualForce page:
<apex:page controller="TCSearchCon" tabstyle="Card__tab"> <apex:sectionheader title="Search Contacts & Leads"/> <apex:image id="banner" value="{!$Resource.banner}"/><br/> <apex:pageblock > <apex:pagemessages > stuff </apex:pagemessages> <apex:form id="search"> <apex:inputTextarea id="searchText" rows="1" cols="50" value="{!searchText}"/> <apex:selectList size="1" title="Search for..." value="{!searchType}"> <apex:selectOption value="{!searchTypes}"/> </apex:selectList> <p/> <apex:commandbutton action="{!submit}" value="Search" rerender="resultsPanel" status="status"/> <apex:commandbutton action="{!settings}" value="Settings"/> </apex:form> <apex:outputPanel id="resultsPanel"> <apex:actionstatus id="status" startText="Searching..."> <apex:facet name="stop"> <apex:outputPanel > <apex:outputText value="{!result}"/> </apex:outputPanel> </apex:facet> </apex:actionstatus> </apex:outputPanel> </apex:pageblock></apex:page>
And the Apex code:
public class TCSearchCon { public List<SelectOption> getsearchTypes() { List<SelectOption> searchTypes = new List<SelectOption>(); searchTypes.add(new SelectOption('Name', 'name')); searchTypes.add(new SelectOption('Email', 'email')); searchTypes.add(new SelectOption('Company Name', 'company')); return searchTypes; } public List<SelectOption> searchTypes = getSearchTypes(); public PageReference settings() { PageReference ref = Page.TCSettings; ref.setRedirect(true); return ref; } public String result { get; set; } public PageReference submit() { PageReference ref = Page.TCSearchList; ref.getParameters().put('searchText', searchText); ref.getParameters().put('searchType', searchType.getValue()); ref.setRedirect(true); return ref; } public SelectOption searchType { get; set; } public String searchText { get; set; } }
Thanks!
Hi,
Please apply follwing change.
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Chamil's Blog