+ Start a Discussion
surya bhaisurya bhai 

what use of extensions in custom controller

 

 

i have one doubt    custom controller have many methods if u want custome business logic  we can define extra method  in custom controller

why are useing the extensions, when  we use  extentions in  custom controller  please let me know  help me.....

Best Answer chosen by Admin (Salesforce Developers) 
vasuroyvasuroy

lets say if u have multiple vf pages  using the same custom controller , and one vf page needs some extra logic , instaed of changing the controller we can can use extension for that vf page

All Answers

Dhaval PanchalDhaval Panchal
We can use extension with StandaradController.

If you are not using standardController, then you can specify your controller name using Controller. But if you want to use standardController and also want to use custom controller then you have to give your custom controller name using "extensions".
SaraagSaraag

This is what I think about it, with custom controller, you can have a base class-custom controller that has all of the common functioality and is shared across your team. Depending on your particular need, you write an extension. I don't add to custom controllers, as I don't want other developers to have to load a 3000 line custom controller just to use one of it's methods.

 

A more advanced usecase would be to use with sharing on custom controller and without sharing on extension to execute part of logic in system context. (only true for custom controller extensions)

 

Personally, I think the reason why we don't add to the custom controller itself is a matter of good software design and depends on the team/use case etc. 

 

Sorry if I misunderstood your question.

 

Saraag.

vasuroyvasuroy

lets say if u have multiple vf pages  using the same custom controller , and one vf page needs some extra logic , instaed of changing the controller we can can use extension for that vf page

This was selected as the best answer
surya bhaisurya bhai

Hi,

 

 

 

ok  fine  but  small doubt   on that swichvation we can define  one more  method  is it possible

 

 

 

Dhaval PanchalDhaval Panchal
Hi vasuroy,

can you please give one simple example/scenario for that? I never used this way.