I have 2 <apex:selectList>. The values of 1 selectList (called Available) are populated from Query. When user selects values from this multi-select selectList, I want to show them immediately in another selectList (called Chosen) just beside it. I'm using actionSupport for this but doesn't seem to work.

Here are the 2 selectLists. On "onclick" event, I'm calling a controller method to put the tasksSelected into TasksChosen

<apex:repeat value="{!MapDep}" var="deptKey">
    <apex:selectList id="Available" value="{!tasksSelected}" multiselect="true" >   
      <apex:actionSupport event="onclick" action="{!AddSelectedTasks}" rerender="chosen"/>
      <apex:selectOptions value="{!MapDep[deptKey]}"/>

    <apex:selectList id="chosen" value="{!tasksSelectedByUser}" multiselect="true">
        <apex:selectOptions value="{!TasksChosen}" />

But the tasksSelected values from the 1st selectList is null!!

    public void AddSelectedTasks(){     
        System.debug('on click------>'+tasksSelected);
        for(String t:tasksSelected){
            TasksChosenList.add(new SelectOption(t, t));

    public List<SelectOption> TasksChosenList = new List<SelectOption>();

    public List<SelectOption> getTasksChosen(){     
        return TasksChosenList;

Above is the Add SelectedTasks Method, the debug that I added is giving null. How do I solve this? Any hints?

Note: The two selectLists are inside an <apex:repeat>!

  • Try to change event="onChange"
    – Peeyush
    Commented Sep 20, 2016 at 6:10
  • hmm I tried, no change! ;)
    – sfdcFanBoy
    Commented Sep 20, 2016 at 6:16
  • FYI,The two selectLists are inside an <apex:repeat>. Does that hint anything
    – sfdcFanBoy
    Commented Sep 20, 2016 at 6:18
  • 1
    BTW, your variable names are different. In your AddSelectedTasks you are adding the SelectOption to TasksChosenList, but in your apex:selectList you are using the TaskChosen field -> <apex:selectOptions value="{!TasksChosen}" />
    – smukov
    Commented Sep 20, 2016 at 6:22
  • 1
    Best if you add to your question the declaration and getter/setter for tasksSelected as that is ending up null.
    – Keith C
    Commented Sep 20, 2016 at 7:35

1 Answer 1


Figured out, the setter for TasksSelectedByUser was wrong, my bad! Thanks @Keith C

public void setTasksSelectedByUser(String[] TasksSelectedByUser){
    this.TasksSelectedByUser = TasksSelectedByUser;

Thanks All, for the comments!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .