You need to sign in to do that
Don't have an account?
![newbiewvfdev newbiewvfdev](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
StandardSetController Pagination question
Hi there,
I have three implementation of pagination for three objects using the StandardSetController. The code is pretty much the same, except the QueryLocator's Query. I want to merge all three into one code, which should be able to handle all three objects. Is this possible? I thought I could change the Query based on a parameter that I pass in for the StandardSetController initialization. But It seem's I can't pass a parameter. I am sure there must be someone who came across this same issue, could someone be kind enough to guide me through this? Thank You.
// instantiate the StandardSetController from a query locator public ApexPages.StandardSetController setController { get { if(setController == null) { setController = new ApexPages.StandardSetController( Database.getQueryLocator([ SELECT Id, Name, CreatedDate, Status__c, CreatedBy.Name FROM Object1__c])); // sets the number of records in each page set setController.setPageSize(5); } return setController; } set; } // indicates whether there are more records after the current page set. public Boolean hasNext2 { get { return setController.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious2 { get { return setController.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumber2 { get { return setController.getPageNumber(); } set; } // returns the first page of records public void first2() { jobs2.first(); } // returns the last page of records public void last2() { setController.last(); } // returns the previous page of records public void previous2() { setController.previous(); } // returns the next page of records public void next2() { setController.next(); }
Please help. Thanks.
You can try this, create a generic page which takes a parameter in it's URL called Object. Now in the controller of your page in the constructor you can read the parameter object and write a logic which builds the query based on the parameter "Object".
Please do let me know if this approach works.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.