You need to sign in to do that
Don't have an account?
dev.shiv1.3478599680068948E12
Unablte to call Paginator Class skiptopage method in other class constructor
Hi friends,
I Had a controller for pagination with methods like PageSize, PageSkipSize, DefaultSize, SkipToSize etc....
I am using this pagination controller in other controller for pagination.
In second class I am calling database.query('My Query here') in constructor by calling pagination controller like as follows...
public class PageToDisplayRecords implements ObjectPaginatorListener{
global ObjectPaginator paginator {get;private set;}
public PageToDisplayRecords(ApexPages.StandardController stdController) {
List<Employee__c> emp = new List<Employee__c>();
emp = Database.query('SELECT Id, Name, Tax__c, PF__c,SL__c FROM Employee__c LIMIT 1000');
List<EmpIdW> paginateIds = new List<EmpIdW>(); //wrapperclass list
paginateIds = buildEmpIdList(emp); //buildEmpIdList is wrapperclassList method calling
paginator.setRecords(paginateIds);
}
}
The above constructor is my first priority such that whenever I come to page the default query will run here.
Here my requirement. When ever I click a page number in the pagination area for example say Page number 5and then I click on the record listed here will direct to ThirdPage(here I am passing a parameter to the newpage with the selected page number). In that page I am having a link(Back to results). If I click on this link it will redirect to previous page passing the pagenumber from the url.
Now with that page number from previous I need to construct the page to the selected page number.
For this I added the code as below
public class PageToDisplayRecords implements ObjectPaginatorListener {
public String pageNumber;
global ObjectPaginator paginator {get;private set;}
public PageToDisplayRecords(ApexPages.StandardController stdController) {
pageNumber = ApexPages.currentPage().getParameters().get('pagenumber');
if(pageNumber != '0'){
paginator = new ObjectPaginator(15,this);
paginator.skipToPage(Integer.valueOf(pageNumber)); // Exception throwing here as "Script-thrown exception"
}
List<Employee__c> emp = new List<Employee__c>();
emp = Database.query('SELECT Id, Name, Tax__c, PF__c,SL__c FROM Employee__c LIMIT 1000');
List<EmpIdW> paginateIds = new List<EmpIdW>(); //wrapperclass list
paginateIds = buildEmpIdList(emp); //buildEmpIdList is wrapperclassList method calling
paginator.setRecords(paginateIds);
}
}
Please help me how can I achieve this. (The above code is just to understand the way of code I have written. As original code is much larger I didnot post)
I Had a controller for pagination with methods like PageSize, PageSkipSize, DefaultSize, SkipToSize etc....
I am using this pagination controller in other controller for pagination.
In second class I am calling database.query('My Query here') in constructor by calling pagination controller like as follows...
public class PageToDisplayRecords implements ObjectPaginatorListener{
global ObjectPaginator paginator {get;private set;}
public PageToDisplayRecords(ApexPages.StandardController stdController) {
List<Employee__c> emp = new List<Employee__c>();
emp = Database.query('SELECT Id, Name, Tax__c, PF__c,SL__c FROM Employee__c LIMIT 1000');
List<EmpIdW> paginateIds = new List<EmpIdW>(); //wrapperclass list
paginateIds = buildEmpIdList(emp); //buildEmpIdList is wrapperclassList method calling
paginator.setRecords(paginateIds);
}
}
The above constructor is my first priority such that whenever I come to page the default query will run here.
Here my requirement. When ever I click a page number in the pagination area for example say Page number 5and then I click on the record listed here will direct to ThirdPage(here I am passing a parameter to the newpage with the selected page number). In that page I am having a link(Back to results). If I click on this link it will redirect to previous page passing the pagenumber from the url.
Now with that page number from previous I need to construct the page to the selected page number.
For this I added the code as below
public class PageToDisplayRecords implements ObjectPaginatorListener {
public String pageNumber;
global ObjectPaginator paginator {get;private set;}
public PageToDisplayRecords(ApexPages.StandardController stdController) {
pageNumber = ApexPages.currentPage().getParameters().get('pagenumber');
if(pageNumber != '0'){
paginator = new ObjectPaginator(15,this);
paginator.skipToPage(Integer.valueOf(pageNumber)); // Exception throwing here as "Script-thrown exception"
}
List<Employee__c> emp = new List<Employee__c>();
emp = Database.query('SELECT Id, Name, Tax__c, PF__c,SL__c FROM Employee__c LIMIT 1000');
List<EmpIdW> paginateIds = new List<EmpIdW>(); //wrapperclass list
paginateIds = buildEmpIdList(emp); //buildEmpIdList is wrapperclassList method calling
paginator.setRecords(paginateIds);
}
}
Please help me how can I achieve this. (The above code is just to understand the way of code I have written. As original code is much larger I didnot post)
Try using the standard set controller for visualforce,
See the links below,
http://forcesecrets.blogspot.in/2011/11/custom-pagination-in-visualforce-made.html
http://blog.jeffdouglas.com/2009/07/14/visualforce-page-with-pagination/
http://www.redpointsolutions.com/add-pagination-to-your-visualforce-pages-using-the-soql-offset-clause
http://blog.cloudclickware.com/2013/04/04/list-pagination-and-record-selection-with-visualforce/
https://www.sundoginteractive.com/sunblog/posts/server-side-pagination-in-apex-visualforce-for-custom-classes
Regards,
Ashish