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
buggs sfdcbuggs sfdc 

Help on pagination class

HI,

Am trying to paginate the below class,somehow hasprevioius & hasNext methods are not working as expected,is my code went some thing wrong please help me out
 
public class activeaccountscont {
public acccont(ApexPages.StandardController controller){}
public list<acccont> zsubLst{get;set;}
public ApexPages.StandardSetController cont {
get {
if(cont == null) {
cont = new ApexPages.StandardSetController(Database.getQueryLocator([select,id,name(Select id,Firstname from Contacts) From Account where Accountid = :ApexPages.currentPage().getParameters().get('id') AND Status__c = 'Active']));
}
return cont;
}
set;
}
public List< acccont > zqu{
get
{
cont.setPageSize(5);
return (List<acccont>) cont.getRecords();
}
}
// returns the first page of records
public void first() {
cont.first();
}
// returns the last page of records
public void previous() {
cont.previous();
}
public void last() {
cont.last();
}
public void next() {
cont.next();
}
public Boolean hasNext {
get {
return cont.getHasNext();
}
set;
}
// indicates whether there are more records before the current page set.
public Boolean hasPrevious {
get {
return cont.getHasPrevious();
}
set;
}

}

 
Jasper WallJasper Wall
When expecting many records in a query’s results, you can display the results in multiple pages by using the OFFSET clause on a SOQL query.
try your query like this,
 
[select,id,name(Select id,Firstname from Contacts) From Account where Accountid = :ApexPages.currentPage().getParameters().get('id') AND Status__c = 'Active' LIMIT 100 OFFSET 10]

Let us know if it helps,

Thanks,
Balayesu