You need to sign in to do that
Don't have an account?
Prashant K.
Constructor not defined: [WrapperController.mywrapper].<Constructor>(List<Account>, List<Contact>)
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.
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.
Change you wrapper class
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;
}
}
to
public class mywrapper
{
public List<Account> acc {get;Private set;}
public List<Contact> con {get;Private set;}
public mywrapper(List<Account> a, List<Contact> c)
{
this.acc = a;
this.con = c;
}
}
All Answers
Change you wrapper class
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;
}
}
to
public class mywrapper
{
public List<Account> acc {get;Private set;}
public List<Contact> con {get;Private set;}
public mywrapper(List<Account> a, List<Contact> c)
{
this.acc = a;
this.con = c;
}
}