In this chapter, we will discuss List Controllers in Salesforce. At times, we need to view a given set of records from a Salesforce object by applying filter criteria. This is achieved by using list controllers which allow you to create Visualforce pages that can display or act on a set of records. The standard list controllers can be used in the following set of objects.
- Account
- Asset
- Campaign
- Case
- Contact
- Contract
- Idea
- Lead
- Opportunity
- Order
- Solution
- User
- Custom objects
Example
We take the example of contact object. We fetch the records from this object and display it using list controllers. To achieve this, we create an apex page with the following code. The code creates a pageblock with column values matching the column names of the contact object.
Upon running the above code, we receive the following output.