Friday, September 14, 2018

controller in salesforce

There are two type of controller in salesforce.

A)Standard controller 

Standard Controller: 

You can refer standard or custom objects inside standard controller but you cannot refer apex class.Most standard and all custom objects have Standard controller. Standard controller and its extensions works in user mode.Standard controller reference pre-built visualforce controller provided by salesforce so we do not need to write apex code.We can extends standard controller by using extension controller.

With standard controller you can use standard actions:

create,edit,delete,save with button or link.


Inside controller you can refer apex class.Only one apex class can be refer at a time. Controller by default works in system mode.The apex class will have all of the logic. we use controller when we want the logic to run in system mode so that user permission are not enforced. 


Under extension you refer apex classes but you cannot refer standard or custom objects. Extension can be used with standard controller or controller.If multiple classes are refered under extension with same method priority is given from left to right.we use extension when we want to add some custom logic to standard controller or override logic of controller. 

No comments:

Post a Comment