Visualforce Controller Extension :In our previous Salesforce Tutorial we have learned about Visualforce Custom controller and in this Salesforce Training Tutorial we are going to learn about visualforce controller extension with simple example.

What is visualforce controller extension ?

Visualforce controller Extension :-If we want to use both custom controller functionality and standard controller functionality we use extension controllers. Extension Controllers begins with Standard controller and extended or overridden with custom controller with custom apex code.

Syntax :- <apex:page standardcontroller = “contact” extensions = “Testclass1, Testclass2?></apex:page>.

Controller extension is the third type of controller which extends the behaviour of standard controller. Controller extensions are used to integrate visualforce page with native user interface. Controller extension can not override the functions of standard buttons.

Custom controllers are used along with standard controllers to become controller extensions. In controller extensions we can use multiple extensions in single visualforce page. Here the extension controller is divided in to smaller controllers. These smaller controllers acts as a subset of the behaviours.

let us see an example of extension controller.

visualforce custom controller0

Above shown code is the class for controller extension. For controller extension a constructor is used to pass a single record or multiple records to the class. StandardController is used to pass  single record to the class and StandardSetcontroller is used to pass multiple records to the class.

controller extensiom

The above shown is the visualforce page using Controller Extension.