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
vishal yadav 86vishal yadav 86 

Can someone explain me what the code does ?

public class Acc_Dynamic 
{
   Public List<AccAll> acl{set;get;}
   Public Acc_Dynamic()
    {
      acl=new List<AccAll>();
        for(Integer i=0;i<10;i++)
        {
          Account acc=new Account();
          acl.add(new AccAll(acc,false));
        }        
    }
    public class AccAll
    {
        Public Account accs{set;get;}
        Public Boolean flag{set;get;}
        public AccAll(Account acs,Boolean flg)
        {
          accs=acs;
          flag=flg;
        }   
    }
}
Best Answer chosen by vishal yadav 86
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi Vishal,
Here AccAll is a wrapper class.A wrapper or container class is a class, a data structure, or an abstract data type which contains different objects or collection of objects as its members.

Here this wrapper is used to make a list which has both account and boolean value in each element.

Whenever this class is invoked the constructor creates a list of type AccAll
public class Acc_Dynamic 
{
   Public List<AccAll> acl{set;get;}
   Public Acc_Dynamic()
    {
      acl=new List<AccAll>();
        for(Integer i=0;i<10;i++)
        {
          //creates an instance of account
          Account acc=new Account();
         /*adding this empty account and boolean value
          as false to the list of wrapper class*/
          acl.add(new AccAll(acc,false));
        }        
    }
//wrapper class to hold account and boolean value
    public class AccAll
    {
        Public Account accs{set;get;}
        Public Boolean flag{set;get;}
        public AccAll(Account acs,Boolean flg)
        {
          accs=acs;
          flag=flg;
        }   
    }
}

Finally a list of 10 elements with each element containing empty account and boolean value as false is created   

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards

All Answers

Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi Vishal,
Here AccAll is a wrapper class.A wrapper or container class is a class, a data structure, or an abstract data type which contains different objects or collection of objects as its members.

Here this wrapper is used to make a list which has both account and boolean value in each element.

Whenever this class is invoked the constructor creates a list of type AccAll
public class Acc_Dynamic 
{
   Public List<AccAll> acl{set;get;}
   Public Acc_Dynamic()
    {
      acl=new List<AccAll>();
        for(Integer i=0;i<10;i++)
        {
          //creates an instance of account
          Account acc=new Account();
         /*adding this empty account and boolean value
          as false to the list of wrapper class*/
          acl.add(new AccAll(acc,false));
        }        
    }
//wrapper class to hold account and boolean value
    public class AccAll
    {
        Public Account accs{set;get;}
        Public Boolean flag{set;get;}
        public AccAll(Account acs,Boolean flg)
        {
          accs=acs;
          flag=flg;
        }   
    }
}

Finally a list of 10 elements with each element containing empty account and boolean value as false is created   

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards
This was selected as the best answer
vishal yadav 86vishal yadav 86
Thanks!!
I need to insert 10 records through visualforce page only if the ckeckbox value is selected.
Now how to achieve the above functionality.
Could you please brief me on this.
vishal yadav 86vishal yadav 86
Can anybody please reply to this??