Newer Version Available

This content describes an older version of this product. View Latest

Building a Custom List Controller

A custom list controller is similar to a standard list controller. Custom list controllers can implement Apex logic that you define to show or act on a set of records.

For example you can create the following custom list controller based on a SOQL query:

The list of sObjects returned by getRecords() is immutable. For example, you can’t call clear() on it. You can make changes to the sObjects contained in the list, but you can’t add items to or remove items from the list itself.

Note

The following Visualforce markup shows how the custom controller above can be used in a page:
You can also create a custom list controller that uses anti- and semi-joins as part of the SOQL query. The following code is implemented as an extension to the account standard controller:
The page that displays these records uses a mix of standard list controller actions, but depends on iterating over the records returned from the custom list controller: