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 

Hi..iam geting the values in Developer console ,but unable to bind to the visualforce page

Hi..Onclicking of the data, iam getting the values of the particular selected data, but while rendering, it is not getting render do any one provide the solution for this.. thanks
Visualforce page:
 
<apex:page controller="testclass7" >
  <apex:form >
   <apex:actionFunction name="passValueToController" action="{!testvalues}" reRender="frm">
            <apex:param name="selectedValue" value="selectedValue" assignTo="{!selectedValue}"></apex:param>
        </apex:actionFunction>
  <apex:repeat value="{!wrapclasslist}" var="a" >
 
        <li style="padding:5px;cursor:pointer;" onclick="passValueToController('{!a.value}'); return false;" > 
                {!a.stateName}
            </li>
        </apex:repeat>
  
   
   <apex:outputPanel id="frm">
   
     statename is: <apex:inputText value="{!wrpclas.stateName}"/> <br/><br/>
   value is: <apex:inputText value="{!wrpclas.value}"/> <br/><br/>
    active is: <apex:inputText value="{!wrpclas.active}"/> <br/><br/>
   
    </apex:outputPanel>
    
  
  </apex:form>
</apex:page>

Apex class:
public class testclass7 {
 public list<wrapperclass> wrapclasslist{get;set;}
 public list<wrapperclass> wrapclassaddedlist {get;set;}
 
  public wrapperclass wrpclas{get;set;}
  public string selectedValue{get;set;}
  
 public testclass7 (){
 wrapclasslist = new list<wrapperclass>();
 wrapclassaddedlist = new list<wrapperclass>();
     string  teststring= ' { "sucess":1,"data": [ {"stateName": "Andrapradesh",  "value": "apx" ,"active":"yes"}, { "stateName": "Telangana",  "value":"tsx","active":"processing-no"}, {"stateName": "Banglore",  "value": "bngx","active":"processing-yes"} , {"stateName": "Maharastra",  "value":"mhx" , "active":"no" }  ] } ';
     Map<String, Object> maptest =   (Map<String, Object>) JSON.deserializeUntyped(teststring);
     system.debug('Afterdeserilizing the values are:'+maptest);
     Object ob = (Object)maptest.get('data');
     system.debug('Afterdeserilizing get the data values are:'+ob);
     String srlze   = System.JSON.serialize(ob);
     system.debug('done serilization of the values:'+srlze);
     wrapclasslist = (list<wrapperclass>)System.JSON.deserialize(srlze,list<wrapperclass>.class);
     system.debug('After binding to the wrapper class the values is:'+wrapclasslist); 
 }
 
  /*
  public void testvalues(){
    system.debug('for Datatable functionality:'+ selectedValue);
    
    for(wrapperclass e: wrapclasslist){
      if(e.value==selectedValue){
      wrapclassaddedlist.add(e);
      
         }
     } 
     */
     
     
    public void testvalues(){
    system.debug('for Datatable functionality:'+ selectedValue);
    for(wrapperclass e: wrapclasslist){
      if(e.value==selectedValue){
      // wrpclas.add(e);
      system.debug(e);
     
      }
     }
  
  }
   public class wrapperclass{
   public string stateName{get;set;}
   public string value{get;set;}
   public string active{get;set;}
    
   }
}

how to display the data Onselecting the data.. 

User-added image
 Please provide your suggestions to render it dependig upon the selection .,
thanks
​​​​​​​Deepika 
Best Answer chosen by Deepikareddy
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi deepika,
You are binding correctly but getting null values in vf page because you are not assigning any value to wrapclas in apex.So it is displaying as null.Assign value to wrapclas.then it will work.
I added a line in testvalues().Try below code
public class testclass7 {
 public list<wrapperclass> wrapclasslist{get;set;}
 public list<wrapperclass> wrapclassaddedlist {get;set;}
 
  public wrapperclass wrpclas{get;set;}
  public string selectedValue{get;set;}
  
 public testclass7 (){
 wrapclasslist = new list<wrapperclass>();
 wrapclassaddedlist = new list<wrapperclass>();
     string  teststring= ' { "sucess":1,"data": [ {"stateName": "Andrapradesh",  "value": "apx" ,"active":"yes"}, { "stateName": "Telangana",  "value":"tsx","active":"processing-no"}, {"stateName": "Banglore",  "value": "bngx","active":"processing-yes"} , {"stateName": "Maharastra",  "value":"mhx" , "active":"no" }  ] } ';
     Map<String, Object> maptest =   (Map<String, Object>) JSON.deserializeUntyped(teststring);
     system.debug('Afterdeserilizing the values are:'+maptest);
     Object ob = (Object)maptest.get('data');
     system.debug('Afterdeserilizing get the data values are:'+ob);
     String srlze   = System.JSON.serialize(ob);
     system.debug('done serilization of the values:'+srlze);
     wrapclasslist = (list<wrapperclass>)System.JSON.deserialize(srlze,list<wrapperclass>.class);
     system.debug('After binding to the wrapper class the values is:'+wrapclasslist); 
 }
 
  /*
  public void testvalues(){
    system.debug('for Datatable functionality:'+ selectedValue);
    
    for(wrapperclass e: wrapclasslist){
      if(e.value==selectedValue){
      wrapclassaddedlist.add(e);
      
         }
     } 
     */
     
     
    public void testvalues(){
    system.debug('for Datatable functionality:'+ selectedValue);
    for(wrapperclass e: wrapclasslist){
      if(e.value==selectedValue){
       wrpclas = e;  //added this line
      system.debug(e);
     
      }
     }
  
  }
   public class wrapperclass{
   public string stateName{get;set;}
   public string value{get;set;}
   public string active{get;set;}
    
   }
}
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.

Thanks and Regards
 

All Answers

Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi deepika,
You are binding correctly but getting null values in vf page because you are not assigning any value to wrapclas in apex.So it is displaying as null.Assign value to wrapclas.then it will work.
I added a line in testvalues().Try below code
public class testclass7 {
 public list<wrapperclass> wrapclasslist{get;set;}
 public list<wrapperclass> wrapclassaddedlist {get;set;}
 
  public wrapperclass wrpclas{get;set;}
  public string selectedValue{get;set;}
  
 public testclass7 (){
 wrapclasslist = new list<wrapperclass>();
 wrapclassaddedlist = new list<wrapperclass>();
     string  teststring= ' { "sucess":1,"data": [ {"stateName": "Andrapradesh",  "value": "apx" ,"active":"yes"}, { "stateName": "Telangana",  "value":"tsx","active":"processing-no"}, {"stateName": "Banglore",  "value": "bngx","active":"processing-yes"} , {"stateName": "Maharastra",  "value":"mhx" , "active":"no" }  ] } ';
     Map<String, Object> maptest =   (Map<String, Object>) JSON.deserializeUntyped(teststring);
     system.debug('Afterdeserilizing the values are:'+maptest);
     Object ob = (Object)maptest.get('data');
     system.debug('Afterdeserilizing get the data values are:'+ob);
     String srlze   = System.JSON.serialize(ob);
     system.debug('done serilization of the values:'+srlze);
     wrapclasslist = (list<wrapperclass>)System.JSON.deserialize(srlze,list<wrapperclass>.class);
     system.debug('After binding to the wrapper class the values is:'+wrapclasslist); 
 }
 
  /*
  public void testvalues(){
    system.debug('for Datatable functionality:'+ selectedValue);
    
    for(wrapperclass e: wrapclasslist){
      if(e.value==selectedValue){
      wrapclassaddedlist.add(e);
      
         }
     } 
     */
     
     
    public void testvalues(){
    system.debug('for Datatable functionality:'+ selectedValue);
    for(wrapperclass e: wrapclasslist){
      if(e.value==selectedValue){
       wrpclas = e;  //added this line
      system.debug(e);
     
      }
     }
  
  }
   public class wrapperclass{
   public string stateName{get;set;}
   public string value{get;set;}
   public string active{get;set;}
    
   }
}
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.

Thanks and Regards
 
This was selected as the best answer
DeepikareddyDeepikareddy
Hi Devi,Superb..! Thank you!  I appreciate your help.. take care..!