You need to sign in to do that
Don't have an account?

Standard setcontroller
What is Standard setcontroller?
What are the diffrences between standard controller and standard setcontroller?
I have gone through Salesfroce doc but did not get it.
Can anyone provide a general and understandable approcah.
Thanks
SKT
What are the diffrences between standard controller and standard setcontroller?
I have gone through Salesfroce doc but did not get it.
Can anyone provide a general and understandable approcah.
Thanks
SKT
The difference is that a standardcontroller acts on 1 record and a standardsetcontroller on a set of records.
Basically, the standardcontroller handles your record detail page, whilst the standardsetcontroller handles the object list views.
More information can be found here:
StandardSetController: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_pages_standardsetcontroller.htm
StandardController: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_pages_standardcontroller.htm
Hope this helps.
Happy Coding!
Martijn Schwärzer
All Answers
StandardSetController is a class whose objects allow you to create list controllers similar to, or as extensions of, the pre-built Visualforce list controllers provided by Salesforce.
Below are details on standard controller and StandardSetController which explain the difference between 2.
StandardController
From documentation: 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.
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. For example:
public with sharing class MyController {
private ApexPages.StandardController controller;
public MyController(ApexPages.StandardController controller) {
this.controller = controller;
}
// maybe this gets called from a button within your VF page
public void doSomethingWithSingleRecord() {
SObject record = controller.getRecord();
record.put('Status__c', true);
update record;
}
}
StandardSetController
From documentation: 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.
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. For example:
public with sharing class MyController {
private ApexPages.StandardSetController setController;
public MyController(ApexPages.StandardSetController setController) {
this.setController = controller;
}
//maybe this gets called from a button on your list view
public void doSomethingWithMultipleRecords() {
List<SObject> records = setController.getSelected();
for(SObject record : records) {
record.put('Status__c', true);
}
update records;
}
}
Thanks,
Puneet
The difference is that a standardcontroller acts on 1 record and a standardsetcontroller on a set of records.
Basically, the standardcontroller handles your record detail page, whilst the standardsetcontroller handles the object list views.
More information can be found here:
StandardSetController: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_pages_standardsetcontroller.htm
StandardController: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_pages_standardcontroller.htm
Hope this helps.
Happy Coding!
Martijn Schwärzer