Controller Extensions Part 1
Chapter Topics
- What is Visualforce in Salesforce?
- Architecture of Visualforce Page
- Standard Controller in Visualforce
- How to create View Page in Visualforce?
- How To Create Edit Page In Visualforce?
- Custom Controller in Salesforce
- Getter, Setter Method Part 1
- Getter, Setter Method Part 2
- Apex Page Message in Visualforce
- Controller Extensions Part 1
- Controller Extensions Part 2
- Using Controller Extension with Custom Controller
- Order of Execution
- Tabs in Visualforce
- System Mode in Visualforce
What Is Controller Extension In Visualforce?
Extensions are apex classes used to provide addition functionalities to vf page other than controller.
Code Example Of Controller Extension
Here is the below example code for a standard controller extension class
public class SampleExtension {
private ApexPages.StandardController stdController;
public SampleExtension(ApexPages.StandardController controller) {
stdController = controller;
}
public String getAccountName() {
// Accessing the standard controller's record
Account acc = (Account)stdController.getRecord();
return acc.Name;
}
}
Here is the below example code for a vf page having a standard controller and extension
public class SampleExtension {
private ApexPages.StandardController stdController;
public SampleExtension(ApexPages.StandardController controller) {
stdController = controller;
}
public String getAccountName() {
// Accessing the standard controller's record
Account acc = (Account)stdController.getRecord();
return acc.Name;
}
}
Need more support?
Get a head start with our FREE study notes!
Learn more and get all the answers you need at zero cost. Improve your skills using our detailed notes prepared by industry experts to help you excel.