+ Start a Discussion

How to get selected items from enhancedList?


I'm having a deal with enhancedList component.
I cannot figure out how to get selected items from there.  
I've tried to do it like for selectList but it doesn't work.

Please advise how to access selected items in enhancedList from controller.
Any suggestions would be appreciated.



see example:

<apex:page controller="sampleCon">
<apex:selectList value="{!countries}" multiselect="true">
<apex:selectOptions value="{!items}"/>
<apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
<apex:outputPanel id="out">
<apex:actionstatus id="status" startText="testing...">
<apex:facet name="stop">
Standard Component Reference apex:selectList
<p>You have selected:</p>
<apex:dataList value="{!countries}" var="c">{!c}</apex:dataList>
/*** Controller: ***/
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;




use system.debug to understand the code logic.

use outputlevel tag in VF page and see the output.


This is an example for selectList from guide, not for enhancedList.

This approach doesn't seem to be working with enhancedList.


So is this not possible?