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
DeepikareddyDeepikareddy 

Working with the REPEAT FUNCTIONALITY in salesforce

iam getting an error while addding the data to the Selectlist using the Repeat functionality ..!
public class test5 {

  public list<string> lststatename{get;set;}
  public list<string> lstrating{get;set;}
  
  public list<string> lstactive{get;set;}
  public map<string, string> statemap{get;set;}

 
 public test5(){
 
 
    string  jsonexample1 =  ' { "overalldata": [ {"stateName": "Andrapradesh",  "rating": "5.0" , "active": "yes" }, { "stateName": "Telangana",  "rating": "4.0" ,"active": "no" }, {"stateName": "Banglore",  "rating": "5.0" ,"active": "no"} , {"stateName": "Maharastra",  "rating": "4.5" ,"active": "no" }  ] } ';

   
     map<string,object>  metadatamap= (map<string,object>)json.deserializeuntyped(jsonexample1); 
     
      list<object>  values1= (list<object>)metadatamap.get('overalldata');
        
        
         lststatename= new list<string>();
         lstrating= new list<string>();
         statemap= new map<String, string>();
         
          for(object parsed : values1){
          map<string,object>  values = (map<string,object>)parsed;
          string statename = string.valueof(values.get('stateName'));
          
          string rating= string.valueof(values.get('rating'));
          
          lststatename.add(statename);
             
          lstrating.add(rating);
             
             statemap.put(statename,rating);
             
             }
            
 }
}

Visualforce page:
 
<apex:page controller="test5" >

 <apex:form >
   <apex:repeat value="{!statemap}" var="a">
    <apex:selectList  value="{!selectedvalue}">   
               <apex:selectOptions value="{!a}">{!a}</apex:selectOptions>
<apex:actionsupport event="onchange" />
         </apex:selectList>
   
   </apex:repeat>
            
    The selected value is:{!selectedvalue} and rating is:                                       
      
 
 </apex:form>
 
</apex:page>
//to add the label as the statename and its value as the rating.. onchange should ahave to display ..!
 
Maria Alexander 19Maria Alexander 19
Hi Deepikareddy,

What Kind of ERROR you are getting you are getting.
 
DeepikareddyDeepikareddy
Hii..! Maria Alexander>>!

Visualforce Error
Help for this Page
Invalid selectOptions found. Use SelectOption type in Apex.