StandardSetController Class
===================
-StandardSetController objects allow you to create list controllers similar to, or as extensions of, the pre-built Visualforce list controllers provided by Salesforce.
-This is useful for writing pages that perform mass updates (applying identical changes to fields within a collection of objects).
-Fields that are required in other Salesforce objects will keep the same requiredness when used by the prototype object.
Instantiation
========
-You can instantiate a StandardSetController in either of the following ways:
-From a list of sObjects:
List
ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(accountList);
-From a query locator:
ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Name,CloseDate FROM Opportunity]));
-Note:
-The maximum record limit for StandardSetController is 10,000 records.
-Instantiating StandardSetController using a query locator returning more than 10,000 records causes a LimitException to be thrown.
-However, instantiating StandardSetController with a list of more than 10,000 records doesn’t throw an exception, and instead truncates the records to the limit.
Methods
=======
-StandardSetController methods are all called by and operate on a particular instance of a StandardSetController.
Example
======
The following example shows how a StandardSetController object can be used in the constructor for a custom list controller:
public class opportunityList2Con {
// ApexPages.StandardSetController must be instantiated
// for standard list controllers
public ApexPages.StandardSetController setCon {
get {
if(setCon == null) {
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT Name, CloseDate FROM Opportunity]));
}
return setCon;
}
set;
}
// Initialize setCon and return a list of records
public List
return (List
}
}
The following Visualforce markup shows how the controller above can be used in a page: