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
Aruna06Aruna06 

how to save values using apex:repeat

Hi all,

 

   I have a requirement of saving 5 values from inputtext into a single record......When I enter values in inputtext and click save, in debug log I can see that it is setting the values but unable to get those values......Can anyone help me in this issue, how can I get the values

 

                       <apex:repeat value="{!selectlayout}" var="layout" >                        
                        <apex:outputpanel layout="Block">                      
                             <apex:image value="{!layout.Image1}" height="30" width="30" />
                            
                            <apex:outputText value="{!layout.label1}" /> &nbsp; &nbsp; &nbsp;                          
                          
                            <apex:inputtext value="{!layout.layoutname}" rendered="{!layout.Text1='Textbox'}" size="25"/>                             <br/>
                            
                           <apex:inputtextarea rendered="{!layout.Text1='Textarea'}" /> <br/>
                 
                                             
                              </apex:outputpanel>                                                                       
                                                                                            
                    </apex:repeat>

               <apex:commandButton value="Save" action="{!Save}" />          

 

 

 

 

      public class FieldClass{
        public string label1{get;set;}
        public string Text1{get;set;}
         public string Image1{get;set;}
         public string layoutname{get;set;}  
      } 
 public void Save()
   {
    system.debug('Displayedvalueee'+layoutname);

}

      

Anup JadhavAnup Jadhav

To be able to retrieve the updated values you can retrieve the record again using SOQL in your controller code after you've saved the value, and then assign the value again to the instance fields.

 

- Anup

Aruna06Aruna06

Thanks Anup for ur Quick reply........But what excatly my problem is I'm unable to save the values first I'm getting a null value when I save it.....Can u give me idea how can I save the values..........Here is my controller class

 

 public List<FieldClass> getselectlayout(){
       List<FieldClass> option= new List<FieldClass>();
        try{        
            dataXml=main(url);        
        } catch (System.CalloutException e){        
             System.debug('ERROR:' + e);        
        }
        
        Dom.Document doc = new Dom.Document();
        doc.load(dataXml);  
        Dom.XMLNode CategoryList = doc.getRootElement();  
        Dom.XMLNode Category= CategoryList.getChildElement('Widgets',null);
        string FieldLabel = '';
        string FieldImage = '';
        string FieldText = '' ;
       
        if(CategoryList!=NULL){
                for(Dom.XMLNode child : CategoryList.getChildElements()) {
                 
                   
                    boolean checkCategory=false;                    
                     system.debug('childNodes----'+child.getChildElements());
                    
                         if(child.getName()=='Category')
                          {       
                          
 
                             system.debug('CategoryName111'+child.getAttribute('Name',null));  
                                                                       
                             if(child.getAttribute('Name',null) == Name1){
                                   
                                    checkCategory=true;    
                              }
                           system.debug('Namevalue'+ Name1);
                     
                          }
                       if(checkCategory==true)
                       {               
                         
                        for(Dom.XMLNode subchild : child.getChildElements()) {
                           system.debug('subchild'+subchild);
                           boolean checktemp=false;
                          if(subchild.getName()=='Widget'){
                          system.debug('sunName'+subchild.getAttribute('Name',null));
                                                                  
                                 FieldLabel  = subchild.getAttribute('Name',null);
                                 system.debug('11111'+FieldLabel);
                                  checktemp=true;
                                for(Dom.XMLNode sub_subchild : subchild.getChildElements()) {
                                 Fieldclass Field1 = new Fieldclass() ;     
                              system.debug('sub_subchild'+sub_subchild.getName());
                          
                               if(sub_subchild.getName()=='FieldLabel'){
                          
                             system.debug('sub_subchild1'+sub_subchild.getAttribute('Image',null));
                                                                         
                             system.debug('sub_subchild11'+sub_subchild.getAttribute('FieldType',null));
                        
                            Field1.Image1 = sub_subchild.getAttribute('Image',null);
                            Field1.Text1= sub_subchild.getAttribute('FieldType',null);
                             Field1.label1 = sub_subchild.getText();
                             system.debug('allimages'+Field1.Image1);
                             option.add(Field1);                                                    
                           }                                                       
                          }
                         }                               
                          system.debug('checktemp'+checktemp);
                        }
                     }
                }
             }
        system.debug('finalvalues'+option);
        return option;

}