You need to sign in to do that
Don't have an account?
Praveen Kumar 94
Controller
Trying to display one record at a time using ActionPoller. But i am unable to do it. Says"De-reference a null object. Below is the code.
<apex:page controller="polling" > <apex:form > <apex:pageBlock id="myBlock" > <apex:actionPoller rerender="myTable,myBlock" action="{!displaymeth}" interval="5" status="St"/> <apex:pageBlockTable value="{!apps}" var="a" id="myTable"> <apex:column value="{!a.name}"/> <apex:column value="{!a.City__c}"/> </apex:pageBlockTable> <apex:actionStatus startText="Getting.." stopText="Done" id="St"/> </apex:pageBlock> </apex:form> </apex:page>
Controller
public with sharing class polling { private integer listid = 0; public List<Applicant__C> applist = new List<Applicant__C>(); public PageReference displaymeth() { if(listid <= applist.size()) { if(listid == applist.size()) { listid = 0; } apps.clear(); Applicant__c obj = new Applicant__C() ; obj = applist.get(listid); system.debug('object is here' + obj); apps.add(obj); system.debug('apps is here' + apps); } listid++; return null; } public List<Applicant__C> apps { get; set; } public polling() { applist = [select name, city__c from Applicant__c]; system.debug('List is here' + applist); } }
This should solve your issue.