+ Start a Discussion
Karthick RajaKarthick Raja 

Standard and Custom List Controller

Hi folks,
           Can anyone tell me what is the purpose of custom list controller and Standard List controller?
I need a simple description for that 

Thanks in advance
Virendra ChouhanVirendra Chouhan
Hello Karthick,

Standard and Custom list controllers allow you to create Visualforce pages that can display or act on a set of records.
If you use StandardController in a page then simply use RecordSetVar attribute (this is a collection of all the records of that perticular object).
<apex:page standardController="Account" recordSetVar="accounts">
So in the above example the accounts store all the records from Account object and now you can display them or act any opration on it.

And now about Custom list Controller- It is similer as Standard list Cotroller but you have to use Apex coding in custom controller or in extension.

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();

Here you create setCon in which all the reocrds are stored and set it into a Opportunity list.
So now in Vf page you can display this list or perform any opration on it.

you can find the code here-

hope it'll help you.