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
sriganeshsriganesh 

why we are using constructor in controllers

why we are using constructor in controller

LVSLVS

The reason why we use constructors in any OO language - to initialize class variables and perform some basic computation. In case of controllers, we can use it run a query or calculate a value or if a particular field on the page has to be rendered or not and so forth.

 

Note that to make DML operations we need to use a method attached to the action attribute of the page - this is a salesforce restriction