You need to sign in to do that
Don't have an account?
Surendra nune
Difference between StandardSetController(querylocator) & StandardSetController(List<Sobject>)?
Hi,
I am using standard set controller with querylocator for pagination of records. But the problem with using StandardSetController(querylocator) is that if the vf page is idle for 15 minutes and if we try to paginate the records after 15 minutes, am getting the below exception:
Going through the documentation provided by salesforce, I came to know that query loctors expire every 15mins. https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_querymore_querylocator.htm
So, I thought of using other constructor StandardSetController(List<Sobject). What I wanted to understand is, when do we use StandardSetController(querylocator)? Can any one explain me with a scenario.
I am using standard set controller with querylocator for pagination of records. But the problem with using StandardSetController(querylocator) is that if the vf page is idle for 15 minutes and if we try to paginate the records after 15 minutes, am getting the below exception:
Going through the documentation provided by salesforce, I came to know that query loctors expire every 15mins. https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_querymore_querylocator.htm
So, I thought of using other constructor StandardSetController(List<Sobject). What I wanted to understand is, when do we use StandardSetController(querylocator)? Can any one explain me with a scenario.
query = 'Select name ,id, phone from Account '+strFilter+ ' limit 1000';
System.debug('Query ---->'+ query );
con = new ApexPages.StandardSetController(Database.getQueryLocator(query));
con.setPageSize(2);
Please let us know if this will help you
All Answers
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_pages_standardsetcontroller.htm
You can instantiate a StandardSetController in either of the following ways:From a list of sObjects: From a query locator: The following are constructors for StandardSetController.
StandardSetController(sObjectList)
Creates a new instance of the ApexPages.StandardSetController class for the list of sObjects returned by the query locator.
StandardSetController(controllerSObjects)
Creates a new instance of the ApexPages.StandardSetController class for the specified list of standard or custom objects.
https://developer.salesforce.com/docs/atlas.en-us.198.0.pages.meta/pages/apex_ApexPages_StandardSetController_constructors.htm
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_ApexPages_StandardSetController_methods.htm
Please let us know if this will help you
Thanks
Amit Chaudhary
Thanks for the reply. I have an idea of what are the possible ways to instantiate StandardSetController. My question is when to use StandardSetController(Querylocator) and what is the use of it ? Could please answer this?
query = 'Select name ,id, phone from Account '+strFilter+ ' limit 1000';
System.debug('Query ---->'+ query );
con = new ApexPages.StandardSetController(Database.getQueryLocator(query));
con.setPageSize(2);
Please let us know if this will help you
I tried giving
even this works.