+ Start a Discussion
Ravi Kumar 259Ravi Kumar 259 

when u used extension controller? why we go for this even we have above.?

PratikPratik (Salesforce Developers) 
Hi Ravi,

Extension is usually used from a reusbale code perspective. If i have some functionality in one class and i want to use it somewhere else also then instead of coding that part, you can add an extension to the controller and reuse the code used in extension class.

Amit Chaudhary 8Amit Chaudhary 8
Standard Controller
to associate a page with the standard controller for a custom object named MyCustomObject, use the following markup
<apex:page standardController="MyCustomObject__c">

Standard controllers can provide all the functionality you need for a Visualforce page because they include the same logic that is used for a standard page. For example, if you use the standard Accounts controller, clicking a Save button in aVisualforce page results in the same behavior as clicking Save on a standard Account edit page.

<apex:page standardController="Account" extensions="myControllerExtension">
public class myControllerExtension {
   private final Account acct;
    public myControllerExtension(ApexPages.StandardController stdController) {
        this.acct = (Account)stdController.getRecord();