function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
yaramareddy radhikayaramareddy radhika 

What is the difference between StandardController, Apexpages.StandardController and Apexpages.StandardSetController?

Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Radhika,
  • ApexPages.StandardController (documentation) encapsulates just a single Sobject (e.g. Account, Opportunity).
 
  • ApexPages.StandardSetController (documentation) 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.
I hope it will be helpful.

Please mark it as best answer if resolved the issue.

BestRegards,
RahulKumar.
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for more information
1) http://salesforce.stackexchange.com/questions/112380/diffrence-between-standardcontroller-and-standardsetcontroller
2) http://salesforce.stackexchange.com/questions/48199/what-is-the-difference-between-list-controllers-and-set-controllers
3) https://www.slideshare.net/developerforce/df121239-ready

StandardController Class
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_pages_standardcontroller.htm

StandardController objects reference the pre-built Visualforce controllers provided by Salesforce. The only time it is necessary to refer to a StandardController object is when defining an extension for a standard controller. StandardController is the data type of the single argument in the
extension class constructor.
public class myControllerExtension {

    private final Account acct;
    
    // The extension constructor initializes the private member
    // variable acct by using the getRecord method from the standard
    // controller.
    public myControllerExtension(ApexPages.StandardController stdController) {
        this.acct = (Account)stdController.getRecord();
    }

    public String getGreeting() {
        return 'Hello ' + acct.name + ' (' + acct.id + ')';
    }
}

StandardSetController Class

StandardSetController objects allow you to create list controllers similar to, or as extensions of, the pre-built Visualforce list controllers provided by Salesforce

The StandardSetController class also contains a prototype object. This is a single sObject contained within the Visualforce StandardSetController class. If the prototype object's fields are set, those values are used during the save action, meaning that the values are applied to every record in the set controller's collection. This is useful for writing pages that perform mass updates (applying identical changes to fields within a collection of objects).
 
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;
        }
        set;
    }

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

Let us know if this will help you

 
Goku ZeusGoku Zeus
If you have a considerable amount of precious metals and want to acquire the best price, ACHATDOR.CH offers you advantageous terms.
https://achatdor.ch/
Preston SilvaPreston Silva
Good morning! Have you ever thought about using a professional buyessay (https://essaysrescue.com/buyessay-review/) service for writing an essay? Professional services make it easier to get great results without spending too much time and effort. With their help, you can make sure that your essay will be high-quality and unique. Farewell!