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

Am new to salesforce Trying to Understand extension_controller's constructor
//This is an extension controller class
public class Speaker_conf_extension {
private final Speaker__c speaker; // speaker__c is custom object and standard controller which is using This(Speaker_conf_extension) //extension class
private ApexPages.StandardController sController;
public Speaker_conf_extension(ApexPages.StandardController scontroller) {
this.speaker= (speaker__C)scontroller.getRecord();
this.scontroller = scontroller;
}
public PageReference save() {
..................................
...............................
...............
return null;
}
This extension_controller is trying to over ride Save button and insert an InputFile field to upload image.
I didn't understand what the constructor of extension_controller is doing . Please explain the behaviour ,Thank you
public class Speaker_conf_extension {
private final Speaker__c speaker; // speaker__c is custom object and standard controller which is using This(Speaker_conf_extension) //extension class
private ApexPages.StandardController sController;
public Speaker_conf_extension(ApexPages.StandardController scontroller) {
this.speaker= (speaker__C)scontroller.getRecord();
this.scontroller = scontroller;
}
public PageReference save() {
..................................
...............................
...............
return null;
}
This extension_controller is trying to over ride Save button and insert an InputFile field to upload image.
I didn't understand what the constructor of extension_controller is doing . Please explain the behaviour ,Thank you
A controller extension is any Apex class containing a constructor that takes a single argument of type ApexPages.StandardController or CustomControllerName, where CustomControllerName is the name of a custom controller you want to extend.
For controller extension ,a constructor is used to pass a single record or multiple records to the class.
Please let me know if that helps you.
If it helps don't forget to mark this as a best answer!!!
A controller extension is an Apex class that extends the functionality of a standard or custom controller. Use controller extensions when:You want to leverage the built-in functionality of a standard controller but override one or more actions, such as edit, view, save, or delete.
You want to add new actions.
You want to build a Visualforce page that respects user permissions. Although a controller extension class executes in system mode, if a controller extension extends a standard controller, the logic from the standard controller does not execute in system mode. Instead, it executes in user mode, in which permissions, field-level security, and sharing rules of the current user apply.
please refer below links these will give an overview of controller extension!!!
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm
https://developer.salesforce.com/page/Introduction_to_Controllers_and_Extensions
hope this will help you, if it solve your problem please mark it as a 'best answer'
thank you,