You need to sign in to do that
Don't have an account?

error: Attempt to de-reference a null object at EmployeeOnLeave.add(l);
Vf page
controller
please help me
Regards,
Akshata
<apex:pageBlock rendered="{!(EmployeeOnLeave.size>0)}"> <apex:outputPanel id="EmployeeOnLeave"> <apex:pageBlockTable value="{!EmployeeOnLeave}" var="l" id="EmpOnLeave" title="Employee on Leave today"> <apex:column headerValue="Name" value="{!l.Resource__r.Name}" /> <apex:column headerValue="To Date" value="{!l.To_Date__c}" /> <apex:column headerValue="Type" value="{!l.Type__c}" /> <apex:column headerValue="Status" value="{!l.Decision__c}" /> </apex:pageBlockTable> </apex:outputPanel> </apex:pageBlock>
controller
public List<Leave__c> EmployeeOnLeave{set;get;} public void getEmployeeLeave(){ date dt=date.today(); system.debug(dt); List<Leave__c> AllLeaveList=new List<Leave__c>(); AllLeaveList=[Select Resource__r.Name,From_Date__c,To_Date__c,Type__c,Decision__c From Leave__c where Decision__c=:'Approved']; system.debug(AllLeaveList); if(AllLeaveList.size()>0){ for(Leave__c l:AllLeaveList){ system.debug(l); if(dt>=l.From_Date__c && dt<=l.To_date__c){ EmployeeOnLeave.add(l); } system.debug(EmployeeOnLeave); } } }Error is at EmployeeOnLeave.add(l);
please help me
Regards,
Akshata
public void getEmployeeLeave(){
EmployeeOnLeave = new List<Leave__c>();