You need to sign in to do that
Don't have an account?

SelectOption Multiselect="false"
Hi, I'm having issues with the SelectList and setting multiselect to false. To test things out, I tried reverting back to the sample code listed in the cookbook (code below). The only thing (I think) that I changed is the multiselect="true" to multiselect="false" in the Visualforce code below. When the user selects a country and clicks the "Test" button, the name of the country is not displayed on the screen as it should. Also, the debug log shows the following:
15:19:14 DEBUG - ***Begining Page Log for /apexpages/devmode/developerModeContainer.apexpj_id0:j_id1:j_id2: An error occurred when processing your submitted information.
Any thoughts? Thanks!
Code:
<apex:page controller="samplecon"> <apex:form > <apex:selectList value="{!countries}" multiselect="false"> <apex:selectOptions value="{!items}"/> </apex:selectList><p/> <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/> </apex:form> <apex:outputPanel id="out"> <apex:actionstatus id="status" startText="testing..."> <apex:facet name="stop"> <apex:outputPanel > <p>You have selected:</p> <apex:dataList value="{!countries}" var="c">{!c}</apex:dataList> </apex:outputPanel> </apex:facet> </apex:actionstatus> </apex:outputPanel> </apex:page>
Code:
public class samplecon { String[] countries = new String[]{}; public PageReference test() { return null; } public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('US','US')); options.add(new SelectOption('CANADA','Canada')); options.add(new SelectOption('MEXICO','Mexico')); return options; } public String[] getCountries() { return countries; } public void setCountries(String[] countries) { this.countries = countries; } }
Please add it to the documentation.
Thanks, Steve.
I observed this error mainly with SelectLists , where if in value attribute we didnt gave the appropriate value
like {!countries }, instead we should give it as {!countries.Id} or {!countries.Name}.
I have resolved my issue by making this change.
Cheers
Thanks i was having this problem also and VF's post worked perfect. Please make it as the solution for others to use.
AK