Cursor limits for different Force.com features are tracked separately. For example, you can have five Apex query cursors, five batch cursors, and five Visualforce cursors open at the same time.
List<account> accountList = [SELECT Name FROM Account LIMIT 20];
ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(accountList);ApexPages.StandardSetController ssc =
new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Name,CloseDate FROM Opportunity]));StandardSetController methods are all called by and operate on a particular instance of a StandardSetController.
The table below describes the instance methods for StandardSetController.
| Name | Arguments | Return Type | Description |
|---|---|---|---|
| cancel | System.PageReference | Returns the PageReference of the original page, if known, or the home page. | |
| first | Void | Returns the first page of records. | |
| getCompleteResult | Boolean | Indicates whether there are more records in the set than the maximum record limit. If this is false, there are more records than you can process using the list controller. The maximum record limit is 10,000 records. | |
| getFilterId | String | Returns the ID of the filter that is currently in context. | |
| getHasNext | Boolean | Indicates whether there are more records after the current page set. | |
| getHasPrevious | Boolean | Indicates whether there are more records before the current page set. | |
| getListViewOptions | System.SelectOption[] | Returns a list of the listviews available to the current user. | |
| getPageNumber | Integer | Returns the page number of the current page set. Note that the first page returns 1. | |
| getPageSize | Integer | Returns the number of records included in each page set. | |
| getRecord | sObject | Returns the sObject that represents the changes to the selected records.This retrieves the prototype object contained within the class, and is used for performing mass updates. | |
| getRecords | sObject[] | Returns the list of sObjects in the current page set. This list is immutable, i.e. you can't call clear() on it. | |
| getResultSize | Integer | Returns the number of records in the set. | |
| getSelected | sObject[] | Returns the list of sObjects that have been selected. | |
| last | Void | Returns the last page of records. | |
| next | Void | Returns the next page of records. | |
| previous | Void | Returns the previous page of records. | |
| save | System.PageReference | Inserts new records or updates existing records that have been changed. After this operation is finished, it returns a PageReference to the original page, if known, or the home page. | |
| setFilterID | String filterId | Void | Sets the filter ID of the controller. |
| setpageNumber | Integer pageNumber | Void | Sets the page number. |
| setPageSize | Integer pageSize | Void | Sets the number of records in each page set. |
| setSelected | sObjects[] selectedRecords | Void | Set the selected records. |
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<Opportunity> getOpportunities() { return (List<Opportunity>) setCon.getRecords(); } }
<apex:page controller="opportunityList2Con"> <apex:pageBlock > <apex:pageBlockTable value="{!opportunities}" var="o"> <apex:column value="{!o.name}"/> <apex:column value="{!o.closedate}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>