+ Start a Discussion
Sharankumar DesaiSharankumar Desai 

Custom Controller Vs Custom List Controller

Hi Folks,

I am bit confused between Custom Controller and Custom List Controller difference.

The reason being ,In Cunstomer controller i can create a method to return list of accounts which i can use in Visualforce page then what is the use case for me to opt Custom List controller (account).?

What is that i can do with Custom List controller which cannot be achieved with Custom Controller.
Amit Chaudhary 8Amit Chaudhary 8
Building a Custom List Controller
1) https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_custom_list_controller.htm
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
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;

    // Initialize setCon and return a list of records
    public List<Opportunity> getOpportunities() {
        return (List<Opportunity>) setCon.getRecords();

ApexPages.StandardController (documentation (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_pages_standardcontroller.htm)) encapsulates just a single Sobject (e.g. Account, Opportunity).

ApexPages.StandardSetController (documentation (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_pages_standardsetcontroller.htm)) contains a list of records (one or more), and has additional functions to facilitate pagination (moving between pages) and updating a number of records at once.

We can use Standard set controllers provided by salesforce to implement pagination in visualforce. It is very easy to implement pagination using standard set controller. We can easily navigate through pages, move directly to first, last page or to next or previous pages using standard set controller. We can also decide how many records should be displayed in every page. We need to instantiate the StandardSetController and use the standard methods provided by salesforce to leverage the pagination functionality.
1) http://www.sfdcpoint.com/salesforce/pagination-using-standard-set-controller-salesforce/

1) If you want to perform mass delete with checkbox then i will work

Let us know if this will help you