You need to sign in to do that
Don't have an account?
rzs
Assigning values of a select list to a List object in the controller
Hello,
In my VisualForce page i have a select list whose values i want to pass to my Controller when the command button is pressed.
The select list is defined as follows :
<apex:selectList id="member_list" value="{!selectedMembers}" size="10" > <apex:selectOptions value="{!memberNames}"/> </apex:selectList>
The command button is defined as follows :
<apex:commandButton value="Save" action="{!move}" rerender="hiddenBlock"> <apex:param name="selected" value="{!selectedMembers}" assignTo="{!selectedOptions}"/> </apex:commandButton> <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>
If im not mistaken, {!selectedMembers } is the set of all values in my select list.
Now, in my controller, how to define {!selectedOptions} as List <String> object ?
Please help
Thank You.
Define a list of the type of the members which i guess is String
public List<String> selected = new List<String>();
Thanks for the reply imuino.In my controller, i now have :
But im getting the following error .
FYI, the select list gets populated from the AccountContactRole table, but
does not work either.
Where am i going wrong ?
Please help.
Thanks
Perhaps this will help:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_selectOptions.htm
Use List<SelectOption> instead of List<string>
I mean your apex class should contain the following method
public List<SelectOption> getmemberNames()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption ('A', '1'));
options.add(new SelectOption ('B', '2'));
return options;
}
and then define the get set methods for selectedMembers as follows
public void setselectedMembers(List<SelectOption> sops)
{
selectedmembers = sops;
}
public List<SelectOption> getselectedMembers()
{
return selectedMembers;
}