- July 27, 2018 at 12:44 pm #30551chanchal kumar #13
Can anyone compare and contrast custom controllers & controller extensions in Salesforce?
Compare And Contrast Custom Controllers And Controller Extensions.July 30, 2018 at 4:19 am #30584Avnish Yadav #3
Standard controllers can often provide all of the functionality and data that you need for your Visualforce page.
However, you may need to start coding your own controller code if you want then its Custom controller
- Override existing functionality
- Make new actions available to the page
- Customize the navigation
- Use HTTP callouts or web services
- Have greater control of how information is accessed on the page
If you want to keep most of the functionality of a standard or custom controller it is wiser to have an extension
controller extension can extend standard or custom controller.
Thanks.September 19, 2018 at 1:07 pm #35281
- It is an Apex class that implements all of the logic for a page without leveraging a standard controller.
- You can use only one Apex class.
- You can 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 any Apex class containing a constructor that takes a single argument of type ApexPages.
- It provides additional functionality to a controller – either a standard controller or a custom controller.
- You can use multiple Apex classes separated by comma.
- 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.September 23, 2018 at 3:38 am #37077Parul #2
Controller extension is very useful and important concept introduced by the salesforce recently. It gives the power to programmer to extend the functionality of existing custom controller or standard controller.
A Visualforce can have a single Custom controller or standard controller but many controller extensions.
we can say that the custom extension is the supporter of custom or standard controller.
If you want to use completely custom functionality and don’t really need most of the standard object behaviors, custom controller is a good option, but bear in mind, any standard actions you want to use will have to be implemented in your custom class. A page with a custom controller would use the following attribute:
<apex:page controller=”MyApexClass”…> … </apex:page>
Consider one example : If there is one controller written and used by the multiple visualforce pages and one of them needs some extra logic. Then instead of writing that logic to controller class (Which is used by many visualforce pages) we can create a controller extension and apply to that page only.
Please Register to reply to this topic. /