Newer Version Available
StandardSetController Class
Namespace
Usage
Instantiation
- From a list of sObjects:
1List<account> accountList = [SELECT Name FROM Account LIMIT 20]; 2ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(accountList); - From a query locator:
1ApexPages.StandardSetController ssc = 2new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Name,CloseDate FROM Opportunity]));
Example
1swfobject.registerObject("clippy.codeblock-2", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17public class opportunityList2Con {
18 // ApexPages.StandardSetController must be instantiated
19 // for standard list controllers
20 public ApexPages.StandardSetController setCon {
21 get {
22 if(setCon == null) {
23 setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
24 [SELECT Name, CloseDate FROM Opportunity]));
25 }
26 return setCon;
27 }
28 set;
29 }
30
31 // Initialize setCon and return a list of records
32 public List<Opportunity> getOpportunities() {
33 return (List<Opportunity>) setCon.getRecords();
34 }
35}1swfobject.registerObject("clippy.codeblock-3", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<apex:page controller="opportunityList2Con">
18 <apex:pageBlock>
19 <apex:pageBlockTable value="{!opportunities}" var="o">
20 <apex:column value="{!o.Name}"/>
21 <apex:column value="{!o.CloseDate}"/>
22 </apex:pageBlockTable>
23 </apex:pageBlock>
24</apex:page>StandardSetController Constructors
The following are constructors for StandardSetController.
StandardSetController(sObjectList)
Signature
public StandardSetController(Database.QueryLocator sObjectList)
Parameters
- sObjectList
- Type: Database.QueryLocator
- A query locator returning a list of sObjects.
StandardSetController(controllerSObjects)
Signature
public StandardSetController(List<SObject> controllerSObjects)
Parameters
- controllerSObjects
- Type: List<SObject>
- A List of standard or custom objects.
StandardSetController Methods
The following are methods for StandardSetController. All are instance methods.
cancel()
Signature
public System.PageReference cancel()
Return Value
Type: System.PageReference
getCompleteResult()
Signature
public Boolean getCompleteResult()
Return Value
Type: Boolean
getFilterId()
Signature
public String getFilterId()
Return Value
Type: String
getHasNext()
Signature
public Boolean getHasNext()
Return Value
Type: Boolean
getHasPrevious()
Signature
public Boolean getHasPrevious()
Return Value
Type: Boolean
getListViewOptions()
Signature
public System.SelectOption getListViewOptions()
Return Value
Type: System.SelectOption[]
getPageNumber()
Signature
public Integer getPageNumber()
Return Value
Type: Integer
getPageSize()
Signature
public Integer getPageSize()
Return Value
Type: Integer
getRecord()
Signature
public sObject getRecord()
Return Value
Type: sObject
getRecords()
Signature
public sObject[] getRecords()
Return Value
Type: sObject[]
getResultSize()
Signature
public Integer getResultSize()
Return Value
Type: Integer
getSelected()
Signature
public sObject[] getSelected()
Return Value
Type: sObject[]
previous()
Signature
public Void previous()
Return Value
Type: Void
save()
Signature
public System.PageReference save()
Return Value
Type: System.PageReference
setFilterID(filterId)
Signature
public Void setFilterID(String filterId)
Parameters
- filterId
- Type: String
Return Value
Type: Void
setpageNumber(pageNumber)
Signature
public Void setpageNumber(Integer pageNumber)
Parameters
- pageNumber
- Type: Integer
Return Value
Type: Void
setPageSize(pageSize)
Signature
public Void setPageSize(Integer pageSize)
Parameters
- pageSize
- Type: Integer
Return Value
Type: Void
setSelected(selectedRecords)
Signature
public Void setSelected(sObject[] selectedRecords)
Parameters
- selectedRecords
- Type: sObject[]
Return Value
Type: Void