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
basha skbasha sk 

How to display SelectOptions in visualforce from extension?

Hi Everyone,

     I'm trying to display SelectOptions dynamically in visualforce page.but it returns empty value.please anybody having idea let me know


  here from visualforce page 1 i selected some records and trying to display those record field lables in SelectOption in vf page 2. 



    this is my apex class:
------------------------------------

public class CheckAllUsingJavascriptController {

     public List<wrapAccount> wrapperAccountList {get; set;}
     List<LightiningEd__Webinar_Attendees_Status__c> selectedContacts = new List<LightiningEd__Webinar_Attendees_Status__c>();
   
    public String selectedCountry{get;set;}    
    List<Lead> LeadList = new List<Lead>(); 
    List<System.SelectOption> countrieLst ;
    

    
    public CheckAllUsingJavascriptController (Apexpages.StandardController stdcController){  
     countrieLst = new List<System.SelectOption>();
        if(wrapperAccountList == null) {
            wrapperAccountList = new List<wrapAccount>();
            
            for(LightiningEd__Webinar__c a1: [select id,Name,Start_Time__c,Finish_Time__c,Registration_URL__c,Expired__c,SCO_ID__c,Retrival_Date__c,(select id,Name,principal_id__c,Login__c,isLead__c,Attandance_Status__c,Duration_Spend__c,Company_Name__c,City__c,State__c,Country__c,Mobile_Phone__c from LightiningEd__Webinar_Attendees_Statuss__r) from LightiningEd__Webinar__c where id = :ApexPages.currentPage().getParameters().get('Id')]) {
                for(LightiningEd__Webinar_Attendees_Status__c a : a1.LightiningEd__Webinar_Attendees_Statuss__r){
                
                       wrapperAccountList.add(new wrapAccount(a));
                     
                }
            }
        }  
     
    }
 
      
    public List<System.SelectOption> processSelected(){
        
     countrieLst = new List<System.SelectOption>();
     for(wrapAccount cCon: wrapperAccountList){
        if(cCon.selected == true){
        
            selectedContacts.add(cCon.acc);
            
        }
    }

    for(LightiningEd__Webinar_Attendees_Status__c acc : selectedContacts){
    
        system.debug('selected records::::'+acc);
        
         countrieLst.add(new System.SelectOption(acc.Name,'Name'));
         countrieLst.add(new System.SelectOption(acc.LightiningEd__Login__c,'Login'));
         countrieLst.add(new System.SelectOption(acc.LightiningEd__Attandance_Status__c,'Attandance Status'));
         countrieLst.add(new System.SelectOption(acc.LightiningEd__Company_Name__c,'Company Name'));
         countrieLst.add(new System.SelectOption(acc.LightiningEd__City__c,'City'));
         countrieLst.add(new System.SelectOption(acc.LightiningEd__State__c,'State'));
         countrieLst.add(new System.SelectOption(acc.LightiningEd__Country__c,'Country'));
         countrieLst.add(new System.SelectOption(acc.LightiningEd__Mobile_Phone__c,'Mobile Phone'));
         
    }
    
    return countrieLst;
}



    public class wrapAccount {
        
        public LightiningEd__Webinar_Attendees_Status__c acc {get; set;}
        public Boolean selected {get; set;}
        public wrapAccount(LightiningEd__Webinar_Attendees_Status__c a) {
            acc = a;
            selected = false;
        }
    }    
 
    public PageReference returnFields(){
        
        PageReference parentPage = new PageReference('/apex/Webinar_User_Lead_Create');
        parentPage.setRedirect(true);
        return parentPage;
        
    }
}


vf page:1 

---------------------


<apex:page standardController="Webinar__c" tabstyle="Adobe_Webinars__tab" extensions="CheckAllUsingJavascriptController,UpdateWebinarsList,WebinarDetailsReport,RedirectPage" sidebar="false" >
        <script type="text/javascript">
            function selectAllCheckboxes(obj,InputID){
                var inputCheckBox = document.getElementsByTagName("input");    
                for(var i=0; i<inputCheckBox.length; i++){          
                    if(inputCheckBox[i].id.indexOf(InputID)!=-1){                                     
                        inputCheckBox[i].checked = obj.checked;
                    }
                }
            }
        </script>
        <apex:form >
        
             <apex:pageBlock title="Adobe Connect Integration with Salesforce">
             <center>         
               <apex:commandButton value="Register" action="{!doRegistrationForm}"/>     
             </center><br/><br/>
             <apex:pageBlockSection title="{!Webinar__c.Name} Details">
                <apex:outputField value="{!Webinar__c.Name}"/>        
             </apex:pageBlockSection><br/>
              <center>
               <apex:commandButton id="saveBtn" value="Save" action="{!save}" /> 
                 <apex:commandButton id="cancelBtn" value="Cancel" action="{!cancel}" /> 
                 <apex:commandButton id="detleteBtn" value="Delete" action="{!delete}" />               
              </center><br/>         
        </apex:pageBlock>           
            <apex:pageBlock title="{!Webinar__c.Name}  Webinar Attendees ">                       
                      
                    <apex:commandButton action="{!getWebinarAttendees}" value="Update All" style="margin-left:40%"/>            
                <br/><br/>    
            
                <apex:pageBlockTable value="{!wrapperAccountList}" var="w" id="table" title="All Accounts">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!w.selected}" id="inputId"/>
                    </apex:column>

                    <apex:column headerValue="Webinar Attendee Name">                
                           <apex:outputLink value="{!URLFOR($Page.WebinarAttendeeDetails,w.acc.Id,[id=w.acc.Id])}">{!w.acc.name}</apex:outputLink>            
                    </apex:column>                                     
                    
                    <apex:column value="{!w.acc.Login__c}"></apex:column> 
                     <apex:inlineEditSupport event="ondblClick" />
                     <apex:column value="{!w.acc.isLead__c}"></apex:column>
                     <apex:inlineEditSupport event="ondblClick" />
                     <apex:column value="{!w.acc.Attandance_Status__c}"></apex:column>
                     <apex:inlineEditSupport event="ondblClick" />
                     <apex:column value="{!w.acc.Duration_Spend__c}"></apex:column>
                     <apex:inlineEditSupport event="ondblClick" />                 
                     <apex:inlineEditSupport event="ondblClick" />                                   
                     <apex:column value="{!w.acc.Company_Name__c}"/>
                     <apex:inlineEditSupport event="ondblClick" />
                     <apex:column value="{!w.acc.City__c}"></apex:column>  
                     <apex:inlineEditSupport event="ondblClick" />
                     <apex:column value="{!w.acc.State__c}"></apex:column>
                     <apex:inlineEditSupport event="ondblClick" />
                     <apex:column value="{!w.acc.Country__c}"/> 
                     <apex:inlineEditSupport event="ondblClick" />
                     <apex:column value="{!w.acc.Mobile_Phone__c}"/> 
                     <apex:inlineEditSupport event="ondblClick" />                                                                                 
                </apex:pageBlockTable>
                <apex:pageBlockButtons >                   
                    <apex:commandButton action="{!saveStatusChange}" value="Save"/>
                     <apex:commandButton id="cancelBtn1" value="Cancel" action="{!cancel}" />
                     <apex:commandButton id="detleteBtn1" value="Delete" action="{!delete}" />
                     <apex:commandButton id="leadcreate" value="Create Lead" action="{!createLead}"/>
                    <apex:commandButton value="Process Selected" action="{!returnFields}" rerender="table"/> 
                    <!-- apex:commandButton value="Process Selected" action="{!returnFields}" rerender="table"/ --> 
                </apex:pageBlockButtons>
                
    <apex:selectList size="1">
          <apex:selectOptions value="{!countrieLst}"></apex:selectOptions>
      </apex:selectList>
      
            </apex:pageBlock>
        </apex:form>
    </apex:page>


vf page 2 :
----------------

<apex:page standardController="Webinar__c" extensions="CheckAllUsingJavascriptController" sidebar="false">
<apex:form >
 <apex:pageBlock >
<apex:outputLabel > Countries : </apex:outputLabel>
<apex:selectList>
<apex:selectOptions value="{!countrieLst}"/>
</apex:selectList> <br/>
</apex:pageBlock>
</apex:form>
</apex:page>


vf page 2  displays empty list of values .

i'm  successfullt adding all options to the list .i checked in debug logs but when trying to disply in vf pag e2 shows empty list.if anybody having idea please let me know 

Thanks,
Basha