I have created Master-Child heirarchy in VF page both in editable mode.Changes are not saving when i click save button
public class accconhierarchy {
public PageReference abc() {
System.debug('--------------------------------inside the abc');
return null;
}
public PageReference cancel() {
return null;
}
/*public PageReference save() {
return null;
}*/
Private list<account> acc;
public List<accountWrap> accountList { get; set; }
public accconhierarchy (){
List<contactWrap> cw;
accountList = new List<accountWrap>();
acc = [select id,name,industry,billingcountry,createdbyid,(select id,name,email,phone from contacts) from account limit 20];
for(account a:acc){
cw = new list<contactWrap>();
For(contact co : a.contacts){
cw.add(new contactWrap(co));
}
accountList.add(new accountWrap(a,false,cw));
}
}
public PageReference save1() {
System.debug('-------------------------------------------save1');
System.debug('-------------------------------------------accountList:'+accountList);
List<Account> updateAccList = new List<Account>();
List<contactWrap> updateContWrapList = new List<contactWrap>();
List<Contact> updateConList = new List<Contact>();
for(AccountWrap aw: accountList) {
System.debug('-------------------------------------aw.oAccount:'+aw.oAccount);
updateAccList.add(aw.oAccount);
for(ContactWrap cw: aw.contactset) {
System.debug('-------------------------------------cw.oContact:'+cw.oContact);
updateConList.add(cw.oContact);
}
}
if(!updateAccList.isEmpty()) {
update updateAccList;
}
if(!updateConList.isEmpty()) {
update updateConList;
}
return new PageReference('/001/o');
}
public class accountWrap{
public account oAccount{get;set;}
public boolean isSelected{get;set;}
public List<contactWrap> contactset{get;set;}
public accountWrap(account a,boolean b, List<contactWrap> c){
oAccount=a;
isSelected=b;
contactset =c;
}
}
public class contactWrap{
public contact oContact{get;set;}
public boolean isSelected{get;set;}
public contactWrap(contact a){
oContact=a;
isSelected=false;
}
}
}