+ Start a Discussion
renu anamalla 3renu anamalla 3 

Give One Simple scenario On controller Exetensions

What is The Controller&standaradController,ControllerExtension

Give One Simple scenario On controller Exetensions​?
ajay rawat 14ajay rawat 14
Hi Renu
          Standarad controller is created automatically for evey standarad and custom object. It have basic default functionality like save update cancel and delete action.There are certain scenario where you need to override some funtionality or add few more aciton to existing standarad controller then we use controller exetension.Read  scenario :http://salesforce.stackexchange.com/questions/32593/visualforce-overriding-save-button-behavior (http://salesforce.stackexchange.com/questions/32593/visualforce-overriding-save-button-behavior)

But when we donot want default funtionality and want to added our complex business rule/validations then we use custom controller

Ajay Rawat
Rupal KumarRupal Kumar
Hi Renu, 
    A StandardController object that is automatically provided for standard and all custom objects, bindable to a Visualforce page component           with the “standardController” attribute. It provides a reference to a single/list of record to a set of common actions for data processing and             default navigation.

  <apex:page standardController=”Account”>                // standard object
 <apex:page standardController=”customer__c”>        // custom object

Standard controllers provides only built in standard functionality to visualforce pages, such as Save, Edit, Cancel & Delete etc….
We cannot customize/develop our own functionality by using standard controllers. By using custom controllers we can write our own functionality or override existing functionality. Custom controller is an Apex Class developed by us. See the below syntax to define custom controller in visualforce page.

<apex:page Controller=”ControllerName”>

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.

<apex:page Controller=”ControllerName” extensions=”Class1, Class2,..”>

We can use Stnadard controller/ Custom Controller and extensions at a time. But we cannot use Standard controller & Custom controller at a time. See below syntax to understand.

Rupal Kumarhttp://Mirketa.com