function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JBabuJBabu 

Unable to see the selected options...

Hi,

 

I have visualforce page which uses custom settings as select list and when I select few of the names then those needs to be displayed.

I have shown the select opions but I am not able to see the selected values in the output. (ie., after the message "You have chose"  I am not getting any output.

 

CODE

--------

a) controller class


public class customsettingcontroller {

public string ISOSelected {get;set;}

    public PageReference test() {
        return null;
    }

public list<SelectOption> getISOCodes() {
    List <SelectOption> listCodes = new List<SelectOption>();
    for (Country_Code__c cCode : Country_Code__c.getAll().values())     
      listCodes.add(new selectoption(cCode.ISO_Code__c, cCode.Name+'--'+cCode.ISO_Code__c));
        return listCodes;
 }
 
}

 

b) visualforce page

 

<apex:page controller="customsettingcontroller">
 <apex:form >
  <apex:pageBlock title="Country Codes">
     <apex:selectList value="{!ISOSelected}" multiselect="true">
         <apex:selectOptions value="{!ISOCodes}"></apex:selectOptions>         
     </apex:selectList>
     <apex:actionSupport event="onselect" action="{!test}" rerender="output" status="status"/>     
  </apex:pageBlock>
 </apex:form>
 <apex:outputPanel id="output">
     <apex:actionStatus id="status" startText="testing...">
        <apex:facet name="stop">
          <apex:outputPanel >
          You have chose:
            <apex:dataList value="{!ISOSelected}" var="a">{!a}</apex:dataList>
          </apex:outputPanel>
        </apex:facet>
     </apex:actionStatus>
 </apex:outputPanel>
</apex:page>

 

Please help me on this.

 

Thanks,

JBabu.

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

The apex:actionSupport needs to be between the <apex:selectList> and the </apex:selectList>

And it appears the event needs to be "onchange" for this to work. 

 

(Plus using a String array in the controller, as per my previous reply...)

 

 

All Answers

aballardaballard

Since the select list is multiselect, the IsoSelected property needs to be an array or list  (String[]  or List<String>) not just a String. 

 

Not sure if anything else id wrong.      I'm surprised you don't get an error message from this when you run the page....

JBabuJBabu

Hi Aballard,

 

I tried  both options:

 

1.public string[] ISOSelected {get;set;}

 

2. public List<string> ISOSelected {get;set;}

 

But I am not able to see the output. I am not getting any error message also.

 

Am I doing wrong elsewhere??

 

Thanks,

JBabu.

JBabuJBabu

Hi,

 

Can some one help me with this issue?

 

Thanks,

JBabu.

aballardaballard

The apex:actionSupport needs to be between the <apex:selectList> and the </apex:selectList>

And it appears the event needs to be "onchange" for this to work. 

 

(Plus using a String array in the controller, as per my previous reply...)

 

 

This was selected as the best answer
JBabuJBabu

Hi Aballard,

 

It worked liked charm !!!  Thanks a lot for your help.  (Also both "onclick" and "onchange" are working)

 

Thanks,

JBabu.