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
Dileep KumarDileep Kumar 

How I will abstract data from wrapper class and insert into object ?

Please give me some idea or example.

Thanks in advance

Best Answer chosen by Dileep Kumar
Amit Chaudhary 8Amit Chaudhary 8
One simple example of wrapper class to updated account object. I hope that will help u
1) http://amitsalesforce.blogspot.in/2016/03/wrapper-class-in-salesforce-select-all.html
 

All Answers

Amit Chaudhary 8Amit Chaudhary 8
One simple example of wrapper class to updated account object. I hope that will help u
1) http://amitsalesforce.blogspot.in/2016/03/wrapper-class-in-salesforce-select-all.html
 
This was selected as the best answer
Vasani ParthVasani Parth
Dileep - Welcome to this vibrant community

My 2 cents...Say you have to create a Table in your Visualforce Page in other words a PageBlockTable(apex:pageBlockTable). Each row of the table is suppose to show information from a Contact record also some details from the related Account record too. So, it would be nice, it we had a Class(AnAbstract Data Type or a wrapper or a kind of a temporary holder for information) where it could hold the details for each row from different tables:
public class TableRow{
        public String Name      {get;set;}
        public String Phone     {get;set;}
        public String Company   {get;set;}
}
Now, your Apex Controller class will have this:
 
public class WrapperDemoController{
    /*Our Wrapper Class*/
    public class TableRow{
        public String Name      {get;set;}
        public String Phone     {get;set;}
        public String Company   {get;set;}
    }
   
    /*Public Property that will hold all the TableRows and our PageBlockTable can use this Variable   to get the whole List of rows*/
    public List<TableRow> RowList {get; set;}

    /*Constructor that runs a SOQL to get all the Records and build the List. This get executed automatically on the Page Load.*/
    public WrapperDemoController(){

        RowList = new List<TableRow>();
        TableRow tr;

        /*Building the List of TableRows*/
        /*Fetch all the Contacts and then build the List*/
        for(Contact con : [SELECT Name, Phone, Account.Name FROM Contact]){

            tr = new TableRow();
            tr.Name = con.Name;
            tr.Phone = con.Phone;
            tr.Company = con.Account.Name;

            /*Add the TableRow to the List then and there*/
            RowList.add(tr);
        }
    }
}
Now the Visualforce Markup will be:
 
<apex:page controller="WrapperDemoController">
    <apex:pageBlock>
        <apex:pageBlockTable value="{!RowList}" var="row">
            <apex:column value="{!row.Name}"/>
            <apex:column value="{!row.Phone}"/>
            <apex:column value="{!row.Company}"/>
        </apex:pageBlockTable>   
    </apex:pageBlock>
</apex:page>
So, in simpler words wrapper could be thought of as temporary holder/buffer for information lying across different tables queried via a SOQL.

Please mark this as the best answer if this helps