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
Kathir DevanKathir Devan 

Error is in expression '{!Save}' in component <apex:commandButton>

Attempt to de-reference a null object why this err coming.how to resolve this here below my class and VF page code....

please someone help me...

 

controller:

 

public PageReference Save()
{
List<level1s__c> selectLevel1 = new List<level1s__c>();
//this.stdController.save();

/////////// LEVEL1 ///////////////////
List<level1s__c> selectedLevel1 = new List<level1s__c>();

for(Level1sClass cCon: getList1Details() )
{
system.debug('cCon'+cCon.selected);
if(cCon.selected == true)
{
system.debug('firstCCCCCCCCCC:'+cCon.lev1);
selectedLevel1.add(cCon.lev1);
}
}

Level1__c[] levl1= [Select Id from Level1__c where Account__c=: ApexPages.currentPage().getParameters().get('id')];
delete levl1;
if(selectedLevel1 != null)
{
for(level1s__c con : selectedLevel1)
{
system.debug('CCCCCCCCCC:'+con+'\n');
string acctid =ApexPages.currentPage().getParameters().get('id');
List<Level1__c> lvl1obj= new Level1__c[0];
lvl1obj.add(new Level1__c(Name='Level1',Account__c=acctid,cLevel1__c=con.id));
insert lvl1obj;

}
}
///////////////// LEVEL2 //////////////////////
List<level2s__c> selectedLevel2 = new List<level2s__c>();

for(Level2sClass cCon: getList2Details() )
{
system.debug('cCon'+cCon.selected);
if(cCon.selected == true)
{
system.debug('firstCCCCCCCCCC:'+cCon.lev2);
selectedLevel2.add(cCon.lev2);
}
}

Level2__c[] levl2= [Select Id from Level2__c where Account__c=: ApexPages.currentPage().getParameters().get('id')];
delete levl1;
if(selectedLevel2 != null)
{
for(level2s__c con : selectedLevel2)
{
system.debug('CCCCCCCCCC:'+con+'\n');
string acctid =ApexPages.currentPage().getParameters().get('id');
List<Level2__c> lvl2obj= new Level2__c[0];
lvl2obj.add(new Level2__c(Name='Level2',Account__c=acctid,cLevel2__c=con.id));
insert lvl2obj;

}
}

return null;

}

 

 

VF Page:

<body id="classbody">
<apex:form id="form1">
<div class="main_wrapper">
<div class="container-fluid" >
<div class="row-fluid">
<div class="main">
<apex:inputHidden value="{!SearchText}" id="searchTextbox"/>

<div style="background:#fff; margin-left:13px; margin-right:15px; color:#FFF; border-bottom:2px solid #fff;">
<div style="padding-left:40px; padding-bottom:0px;background-image:url('/resource/1382341187000/gradient');"><br/>
<h2 style="color:#333;font-size:18px;">Landscape Details</h2>
<div align="right" style="margin-right:10px;">
<!-- <input type="button" id="btnsave" value="Save" onclick="clntsave();" style="border:0px solid #333; background:#6fb3e0;width:82px; padding:4px; color:#FFF; font-weight:600;border-radius:8px; " />
<input type="button" value="Back To Account" onclick="backtoAccount()" style="border:0px solid #333; background:#6fb3e0;width:142px; padding:4px; color:#FFF; font-weight:600;border-radius:8px; "/> -->
<apex:commandButton action="{!Save}" onclick="clntsave();" style="border:0px solid #333; background:#6fb3e0;width:100px; padding:8px; color:#FFF; font-weight:600;border-radius:16px; " value=" Save "/>
<apex:commandButton onclick="backtoAccount()" style="border:0px solid #333; background:#6fb3e0;width:100px; padding:8px; color:#FFF; font-weight:600;border-radius:16px; " value=" Back To Account"/>
<div style="display:none;" class="msg" id="savemsg">
<br/><b>processing.... </b>
</div>
</div>

testrest97testrest97

which line the error is showing