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>
<apex:selectList id="chosen" value="{!tasksSelectedByUser}" multiselect="true">
<apex:selectOptions value="{!TasksChosen}" />
</apex:selectList>
</apex:repeat>
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>
!
Best Answer
Figured out, the setter for
TasksSelectedByUser
was wrong, my bad! Thanks @Keith CThanks All, for the comments!