I have a requirement where I have to default selected all values on visual force page. I have searched everywhere but I still have no lead to work on it.
Would someone please advise how to do that using controller and visual force page please .
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityI have a requirement where I have to default selected all values on visual force page. I have searched everywhere but I still have no lead to work on it.
Would someone please advise how to do that using controller and visual force page please .
In your page do something like
<apex:selectList size="5" id="selectRev" value="{!selValue}" multiselect="true" >
<apex:selectOptions value="{!MultiValues}"/>
</apex:selectList>
Controller:
public List<SelectOption> getMultiValues() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('value1','value1'));
return options;
}
Public string[] getselValue(){
//Where c.Test_Multi__c would be the name of the field you are storing the value in.
if (c.Test_Multi__c!=null)
return c.Test_Multi__c.split(';');
else
return null;
}
public void setselValue(string[] vals){
c.Test_Multi__c=string.join(vals,';');
}