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

ApexPages.StandardSetController Passing in List Variable?
I'm getting the error "Constructor not defined: [ApexPages.StandardSetController].<Constructor>(List<StoreFront2.DisplayMerchandise). I want to pass in the list of Products I've constructed in the List<DisplayMerchandise> products; variable. How can I accomplish this? Or is there a better way to code this? Thanks.
public class StoreFront2{ List<DisplayMerchandise> products; public StoreFront2(){ ct=new Purchase_Line_Items__c(); ct2=new Contact(); flag = false; flip = false; flag2 = true; } public ApexPages.StandardSetController samplePagination{ get{ if(samplePagination == null){ samplePagination = new ApexPages.StandardSetController(products); samplePagination.setPageSize(5); } return samplePagination; } set; } public class DisplayMerchandise { public Merchandise__c merchandise{get; set;} public Decimal count{get; set;} public Decimal tempCount{get;set;} public DisplayMerchandise(Merchandise__c item){ this.merchandise = item; } } public List<DisplayMerchandise> getProducts() { if (products == null){ products = new List<DisplayMerchandise>(); for (Merchandise__c item : [SELECT id, name, description__c, price__c FROM Merchandise__c WHERE Total_Inventory__c > 0]) { products.add(new DisplayMerchandise(item)); } } return products; } }
As per per "standardsetcontroller" You can instantiate a StandardSetController in either of the following ways :-
From a list of sObjects From a query locator http://amitsalesforce.blogspot.in/2015/04/pagination-using-standardsetcontroller.html
Problem in your code.
You are trying to pass list of wrapper classes not sobject. If you will pass below list it will work Or please check below post how to perform pagination on Wrapper class
http://amitsalesforce.blogspot.in/2014/11/pagination-with-wrapper-class-with.html
Let us know if this will help you
Thanks
Amit Chaudhary
All Answers
Replace your method code with the below code.
Please let me know if you get the same issue.
Thanks,
Naval
Still getting the same error on the same line 19.
As per per "standardsetcontroller" You can instantiate a StandardSetController in either of the following ways :-
From a list of sObjects From a query locator http://amitsalesforce.blogspot.in/2015/04/pagination-using-standardsetcontroller.html
Problem in your code.
You are trying to pass list of wrapper classes not sobject. If you will pass below list it will work Or please check below post how to perform pagination on Wrapper class
http://amitsalesforce.blogspot.in/2014/11/pagination-with-wrapper-class-with.html
Let us know if this will help you
Thanks
Amit Chaudhary
Replace your method code with the below code.
this is will surely work for you.
if you want to do some navigation on record set , Example
so that you can get next record as well you can perform your pration too.