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
Krishnan MishraKrishnan Mishra 

How do i display contents of wrapper class within the repeat tag?

I have a wrapper class that i want to display on a visualforce page using repeat tag. Following is my code 
public class PaginationForComponent {
    public String objName{get;set;}
	public String[] fieldNames{get;set;}
	list<sObject> con = new list<sObject>();

	
	public PaginationForComponent(){
		RecordsPerPageslist = 10;
	}

	public String query;
	public String alphaSearchConct{get;set;}
	public string msg {get;set;}
	public Map<id,Boolean> m = new Map<id,boolean>(); 
	list<sObject> sortedList;
	public String myOrder{get;set;}                 // Ascending or Descending order of sorting
	public String sortField{get;set;}               // Field by which sorting should be done
	public boolean selectAll{get;set;}
	public list<String> alphabet{get;set;}
	public list<sObject> cont;
	public list<wrapper> allContactList = new list<wrapper>();
	public void fieldvalues(){
		query = fieldNames[0] + ' , ';
		for(Integer i=1;i<fieldNames.size();i++){
			query = query + fieldNames[i] + ' , ';
		}
		query='SELECT ' + query + ' FROM ' + 'objName';
	}
	public Integer RecordsPerPageslist{ 
        get;
        set{                                                          //To select number of records per page
            if(value!=null){
                this.RecordsPerPagesList=value;
                System.debug('RecordsPerPageList called');
            }
        }       
    }  
    public ApexPages.StandardSetController stdSetController{            //Instantiating a standard set controller
          get{
              if(stdSetController==null){
                    con = Database.query(query);
                    System.debug('con in ssc is : ' + con);
                   stdSetController = new ApexPages.StandardSetController(con);
              }
                stdSetController.setPageSize(RecordsPerPageslist);        //Limiting Number of records to be displayed per page 
                  System.debug('stdSetController called ');
              return stdSetController;   
          }
          set;
      }
    public list<wrapper> getWrapperContacts(){      //List of wrapper class to display in table
       for(sObject c:(list<sObject>)stdSetController.getRecords()){
       		allContactList.add(new wrapper(c));
       }
        return allContactList;
    }

    public class wrapper{
	  public boolean isSelected{get;set;}  
	  public sObject con{get;set;}  
	  public   wrapper(sObject con){
	          System.debug('constructor of wrapper class called ');
	          isSelected = false;
	          this.con = con;
	          }
	          
	      }
}
 
<apex:component controller="PaginationForComponent" >
    <apex:attribute name="objectName" description="The object's name" type="String" required="true" assignTo="{!objName}"/>
    <apex:attribute name="fieldName" description="Fields to be displayed" type="String[]" required="true" assignTo="{!fieldNames}"/>
    <apex:pageBlock >
        <apex:repeat value="{!getWrapperContacts}" var="repeat">
            <apex:outputText value="{!repeat}">
            
            </apex:outputText>
            
        </apex:repeat>
    
    </apex:pageBlock>
</apex:component>

 
<Saket><Saket>
Hi Try This,
 
<apex:component controller="PaginationForComponent" >
    <apex:attribute name="objectName" description="The object's name" type="String" required="true" assignTo="{!objName}"/>
    <apex:attribute name="fieldName" description="Fields to be displayed" type="String[]" required="true" assignTo="{!fieldNames}"/>
    <apex:pageBlock >
        <apex:repeat value="{!getWrapperContacts}" var="repeat">
                  
                  <apex:repeat value="{!fieldNames}" var="f">
                          
                             <apex:outputText   value="{!repeat.con[f]}"/>

                  </apex:repeat>
                   
        </apex:repeat>
    
    </apex:pageBlock>
</apex:component>

if this get your problem solved then please mark this as the best answer   

Thanks
Saket Sharma
 
Niraj Kr SinghNiraj Kr Singh
Hi Krishnan,

You can try this, and let me know if not working this
<apex:component controller="PaginationForComponent" >
    <apex:attribute name="objectName" description="The object's name" type="String" required="true" assignTo="{!objName}"/>
    <apex:attribute name="fieldName" description="Fields to be displayed" type="String[]" required="true" assignTo="{!fieldNames}"/>
    <apex:pageBlock >
        <apex:repeat value="{!getWrapperContacts}" var="repeat">
                  <apex:inputCheckbox value="{!repeat.isSelected}"/>
                  <br/>
                  <apex:repeat value="{!fieldNames}" var="f">
                       <apex:outputText   value="{!repeat.con[f]}"/><br/>
                  </apex:repeat>
                  <br/> 
        </apex:repeat>
    </apex:pageBlock>
</apex:component>

Thanks
Niraj​