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
hiteshwar marnihiteshwar marni 

VF Page Table

public class sampleclass{
        public list<rows> rows{get;set;}
        public list<String> origin_addresses{get;set;}
        public String status{get;set;}
        public list<String> destination_addresses{get;set;}
        }

I want to display the above variables i.e lists and strings in a single table in VF page.I have gone through wrapper class examples but I didn't got it.Please help me in this.
​Thanks
ashishashish
hi,
Wrapper class is used to to make a collection of Objects , here is an Example :
/*Wrapper class of Account And Contract object that gets their Billing Addresses fields through one table*/

//Apex Class

 public class ContractAccountTask{
  public List<aTableRow> tableRows{get;set;}

  
  string id;
  public class aTableRow{
      
      public Contract   theContract{get;set;} 
      public Account  theAccount{get;set;}
      public Boolean isSelected{get;set;}
      public String name{get;Set;}
      
      public aTableRow(Contract c,Account a,Boolean b,String Name){
          theContract = c;
          theAccount = a;
          isSelected = b;
          this.name=Name;
      }
      
   }
               
    public ContractAccountTask(ApexPages.StandardController controller){
        tableRows=new List<aTableRow>();
      
       
        id=ApexPages.CurrentPage().getParameters().get('id');
        Contract ctrc=[SELECT Accountid,Account.BillingStreet,Account.BillingState,Account.BillingCity,Account.BillingCountry,Account.BillingPostalCode,BillingStreet,BillingState,BillingCity,BillingPostalCode,BillingCountry FROM Contract Where id=:id];
        
           tableRows.add(new aTableRow(ctrc,ctrc.Account,false,'BillingStreet'));
           tableRows.add(new aTableRow(ctrc,ctrc.Account,false,'BillingCity'));
           tableRows.add(new aTableRow(ctrc,ctrc.Account,false,'BillingState'));
           tableRows.add(new aTableRow(ctrc,ctrc.Account,false,'BillingPostalCode'));
           tableRows.add(new aTableRow(ctrc,ctrc.Account,false,'BillingCountry'));
            
        
    }
    
    public pageReference Activate(){
        for(aTableRow tr:tableRows){
            if(tr.isSelected ==true){
                tr.theAccount.BillingState=tr.theContract.BillingState;
            }
            if(tr.isSelected ==true){
                tr.theAccount.BillingStreet=tr.theContract.BillingStreet;
            }

           if(tr.isSelected ==true){
               tr.theAccount.BillingCity=tr.theContract.BillingCity;
            }
            
            if(tr.isSelected ==true){
                tr.theAccount.BillingPostalCode=tr.theContract.BillingPostalCode;
            }
            if(tr.isSelected ==true){
                tr.theAccount.BillingCountry=tr.theContract.BillingCountry;
            }
            tr.isSelected=false;
        }
        
        pageReference pg=new PageReference('/apex/ContractAccountTask?scontrolCaching=1&id='+id);
        return pg;
    }
}
 
/*the VF page that renders the wrapper class*/

<apex:page standardController="Contract" extensions="ContractAccountTask">
    <apex:form >
        <apex:pageBlock title="Acctivation Page of Contract">
          <apex:pageBlockSection title="Addresss Information">
           <apex:pageBlockTable value="{!tableRows}" var="row">
          
               <apex:column ><apex:inputCheckbox rendered="{!row.name=='BillingStreet'}" value="{!row.isSelected}"/></apex:column>
               <apex:column rendered="{!row.name=='BillingStreet'}" headerValue="Contract Billing street"  ><apex:inputField value="{!row.theContract.BillingStreet}"/></apex:column>
               <apex:column rendered="{!row.name=='BillingStreet'}" headerValue="Account Billing Street" ><apex:inputField value="{!row.theAccount.BillingStreet}"/></apex:column>
              
                
               <apex:column ><apex:inputCheckbox rendered="{!row.name=='BillingCity'}" value="{!row.isSelected}"/></apex:column>
               <apex:column rendered="{!row.name=='BillingCity'}" headerValue="Contract Billing State"><apex:inputField value="{!row.theContract.BillingState}"/></apex:column>
               <apex:column rendered="{!row.name=='BillingCity'}" headerValue="Account Billing State"><apex:inputField value="{!row.theAccount.BillingState}"/></apex:column> 
                
             
              
               <apex:column ><apex:inputCheckbox rendered="{!row.name=='BillingState'}" value="{!row.isSelected}"/></apex:column>
               <apex:column rendered="{!row.name=='BillingState'}" headerValue="Contract Billing City"><apex:inputField value="{!row.theContract.BillingCity}"/></apex:column>
               <apex:column rendered="{!row.name=='BillingState'}" headerValue="Account Billing City"><apex:inputField value="{!row.theAccount.BillingCity}"/></apex:column> 
               
               
              
               <apex:column ><apex:inputCheckbox rendered="{!row.name=='BillingPostalCode'}" value="{!row.isSelected}"/></apex:column>
               <apex:column rendered="{!row.name=='BillingPostalCode'}" headerValue="Contract Billing Code"><apex:inputField value="{!row.theContract.BillingPostalCode}"/></apex:column>
               <apex:column rendered="{!row.name=='BillingPostalCode'}" headerValue="Account Billing Code"><apex:inputField value="{!row.theAccount.BillingPostalCode}"/></apex:column> 
            
               
    
               <apex:column ><apex:inputCheckbox rendered="{!row.name=='BillingCountry'}" value="{!row.isSelected}"/></apex:column>
               <apex:column rendered="{!row.name=='BillingCountry'}" headerValue="Contract Billing Country"><apex:inputField value="{!row.theContract.BillingCountry}"/></apex:column>
               <apex:column rendered="{!row.name=='BillingCountry'}" headerValue="Account Billing Country"><apex:inputField value="{!row.theAccount.BillingCountry}"/></apex:column>-->
             
               </apex:pageBlockTable>
           </apex:pageBlockSection>
          
         <apex:pageBlockButtons >
             <apex:commandButton action="{!Activate}" value="Activate"/>
         </apex:pageBlockButtons>
         
       </apex:pageBlock>
    </apex:form>
</apex:page>