• Prashant K.
  • NEWBIE
  • 15 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi All,

I am new to the Salesforce Platform.I just try to create the vf page which shows account & contact.I go through the wrapper class concept but got below error.

Constructor not defined: [WrapperController.mywrapper].<Constructor>(List<Account>, List<Contact>)

Please find my code Below.

public class WrapperController {
    
    public class mywrapper
    {
        public Account acc {get;Private set;}
        public Contact con {get;Private set;}
        
        public mywrapper(Account a,Contact c)
        {
        this.acc = a;
        this.con = c;
            
        }
    }
    
        public List<mywrapper> wrapperlist {get;private set;} 
        
        public WrapperController()
        {
            List<Id> accid = new List<Id>();
            List<Account> acclist = new List<Account>([SELECT ID,NAME from Account]);
            for(Account iterateacc:acclist)
            {
                accid.add(iterateacc.id);
                
            }
            this.wrapperlist = new list<mywrapper>();
            List<contact> conlist = new List<Contact>([Select Id, Name FROM Contact Where ID IN :accid]);
            wrapperlist.add(new mywrapper(acclist,conlist));
            }
}


Let me correct If I put it something wrong.Thanks in advance.
Hi All,

I am new to the Salesforce Platform.I just try to create the vf page which shows account & contact.I go through the wrapper class concept but got below error.

Constructor not defined: [WrapperController.mywrapper].<Constructor>(List<Account>, List<Contact>)

Please find my code Below.

public class WrapperController {
    
    public class mywrapper
    {
        public Account acc {get;Private set;}
        public Contact con {get;Private set;}
        
        public mywrapper(Account a,Contact c)
        {
        this.acc = a;
        this.con = c;
            
        }
    }
    
        public List<mywrapper> wrapperlist {get;private set;} 
        
        public WrapperController()
        {
            List<Id> accid = new List<Id>();
            List<Account> acclist = new List<Account>([SELECT ID,NAME from Account]);
            for(Account iterateacc:acclist)
            {
                accid.add(iterateacc.id);
                
            }
            this.wrapperlist = new list<mywrapper>();
            List<contact> conlist = new List<Contact>([Select Id, Name FROM Contact Where ID IN :accid]);
            wrapperlist.add(new mywrapper(acclist,conlist));
            }
}


Let me correct If I put it something wrong.Thanks in advance.