function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Lakshmi SLakshmi S 

custom controllers and extensions?

Hi All,

Why we are using custom controller and custom extensions in the same vf page? In which situation we are going to use both custom controller and extensions?

Can anyone reply for this post.......
Thanks in Advance............
Best Answer chosen by Lakshmi S
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for same
1) https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller.htm
2) https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm

User-added image
Standard - these are provided by the platform so you can produce Visualforce pages without writing code. You'd use these when you have a singe object to manipulate. It provides a save method to allow you to persist changes. There's a variant of this that handles a collection of records - the standard list controller.
Custom controller - this is written in Apex and requires you to write code for any behaviour you ned. You'd use these when your page isn't dealing with a main object - e.g. A launch pad that can take you to a number of different sub pages.
Extension controller. This provides additional functionality to a controller - either a standard controller (e.g to manipulate child records along with a parent) or a custom controller (this is often overlooked and is a way to provide common functionality across a number of pages).

1) http://www.salesforcetutorial.com/custom-controllers-controller-extensions/
 

All Answers

Rupal KumarRupal Kumar
Hi,

custom controller is an Apex class that implements all of the logic for a page without leveraging a standard controller. Use custom controllers when you want your Visualforce page to run entirely in system mode, which does not enforce the permissions and field-level security of the current user.
A controller extension is an Apex class that extends the functionality of a standard or custom controller. Use controller extensions when:

=> You want to leverage the built-in functionality of a standard controller but override one or more actions, such as edit, view, save, or delete.
=> You want to add new actions.
=> You want to build a Visualforce page that respects user permissions. Although a controller extension class executes in system mode, if a controller extension extends a standard controller, the logic from the standard controller does not execute in system mode. Instead, it executes in user mode, in which permissions, field-level security, and sharing rules of the current user apply.

Thanks
Rupal Kumar
http://mirketa.com
DeveloperSudDeveloperSud
Hi Lakshmi,

I got a solution for this in stackexchange. Hope this answers your question.
http://salesforce.stackexchange.com/questions/48750/custom-controller-with-extension
 
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for same
1) https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller.htm
2) https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm

User-added image
Standard - these are provided by the platform so you can produce Visualforce pages without writing code. You'd use these when you have a singe object to manipulate. It provides a save method to allow you to persist changes. There's a variant of this that handles a collection of records - the standard list controller.
Custom controller - this is written in Apex and requires you to write code for any behaviour you ned. You'd use these when your page isn't dealing with a main object - e.g. A launch pad that can take you to a number of different sub pages.
Extension controller. This provides additional functionality to a controller - either a standard controller (e.g to manipulate child records along with a parent) or a custom controller (this is often overlooked and is a way to provide common functionality across a number of pages).

1) http://www.salesforcetutorial.com/custom-controllers-controller-extensions/
 
This was selected as the best answer