+ Start a Discussion
Gopinath418Gopinath418 

difference between Listcontroller and Setcontroller in apex

What is the difference between StandardListController and StandardSetController and when could we use listcontroller and when to use Setcontroller?
 
Raj VakatiRaj Vakati
StandardController

 A Visualforce controller is a set of instructions that specify what happens when a user interacts with the components specified in associated Visualforce markup, such as when a user clicks a button or link. Controllers also provide access to the data that should be displayed in a page, and can modify component behavior.

You can find more information here, but basically a StandardController is for ONE record, i.e. if you'd like to create a new Visualforce page for a single record, you'd use a Standard Controller in your Apex. 

StandardSetController

 Standard list controllers allow you to create Visualforce pages that can display or act on a set of records. Examples of existing Salesforce pages that work with a set of records include list pages, related lists, and mass action pages.

You can find more information here, but basically Set (list) controllers are for MULTIPLE (or a list of) records, i.e. if you'd like to create a new Visualforce page for a List of records (or even from a selection of records on a List view), you'd use a Standard Set Controller in your Apex.

Standard List Controller is a logical term that is used when defining a visualforce page for any objects List Controller, using recordSetVar on <apex:page> in conjunction with StandardController. StandardSetController is an Object that refers to these list controllers in Apex Class.

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_pages_standardsetcontroller.htm

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_sosc_about.htm
Gopinath418Gopinath418
Do you mean StandardListController and StandardSetController are same?
If same why do we have two same controllers?

Thanks,
Gopinath