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
Aladdin USAladdin US 

What is the need of “Custom Controller” in Visualforce as everything can be done by the combination of Standard Controller + Extension class.

Deepali KulshresthaDeepali Kulshrestha
Hi Aladdin,

In the context of visualforce, to take advantage of the built-in features of Visualforce to access your org's data, you must use a controller. All controllers are Apex classes, either standard Apex classes (ApexPages.StandardController or ApexPages.StandardSetController) or your own custom Apex class. You can also extend the functionality of any of these with an Extension class.

I tend to be a bit picky with my terminology here. Controllers are controllers. Extensions are not controllers. And for me, the difference is that extensions cannot live by themselves on a page. In other words, I'm not permitted to use extensions, unless my page has a controller in the first place.

Another distinguishing feature is that a page is allowed only one controller ever. But I can add as many extensions as I need.

So let me begin (what has become a dissertation) with controllers:

Controllers are attached to your page using one of three mutually exclusive formats, a standard controller, standard list/set controller, custom controller.

For more detail Please refer to this link:
https://salesforce.stackexchange.com/questions/4041/difference-between-controller-and-extensions/4055

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks.
Deepali Kulshrestha
Banwari KevatBanwari Kevat
Hi Aladdin,
     Question is good.
There some restrictions for Standard Controller + Extension are below
   1. We need to have constructor of extention class which takes ApexPages.StandardController therfore extention required record id for specific sObject.
 2. If our page is not required any specifc sObject related information or action then we go with Custom Controller.

Please let me know if you have any query.

Thanks,
Banwari