Contents
What is the difference between standard controller and custom controller?
The Custom Controller, is one that is used to inherit the Standard Controller’s functionality, whilst allowing to get access to extra information, like: Access data that is not available with a Standard Controller, like more than one level down child or related objects. Create custom behavior (properties or methods)
What is apex extension?
Controller extension in Salesforce is an Apex class containing a constructor that is used to add or extend the functionalities of a Standard Controller or custom controller in Salesforce. Extension controller is also used to leverage the functionality of another controller using our own custom logic.
Which is an example of a controller extension?
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. The following class is a simple example of a controller extension:
How to define custom controller extension in Visualforce?
Controller extension is custom/additional behavior to standard controllers. Extension is an apex class. We can add number of extensions to visualforce page. See below syntax to define extension. We can use Stnadard controller/ Custom Controller and extensions at a time.
What happens when you extend a standard controller?
If the Controller Extension extends a Standard Controller it will execute in user mode in which permissions, field-level security, and sharing rules of the current user apply, even though a controller extension class executes in system mode. Standard controllers: It is used for performing operations on a single record.
How to write unit tests for custom controllers?
Unit test methods take no arguments, commit no data to the database, and are flagged with the testMethod keyword in the method definition. When writing unit tests for controller extension and custom controller classes, you can set query parameters that can then be used in the tests.