A custom controller is an Apex class that is used to execute the logic of a page without the need of a standard controller. To completely run Visualforce pages in system mode, we must utilize custom controllers. This article will teach you all you need to know about Salesforce's Custom Controller.
Custom Controller is defined as an Apex class that executes the logic of a page without using a regular controller. To make your Visualforce pages execute completely in system mode, we have to use custom controllers. Custom controllers in Saelsforce include data manipulation and custom logic which are used by the Visualforce page. Custom Controllers fetch certain items, and the visual force uses them as a controller. It is used to fetch the data that is to be displayed on the visualforce page.
In salesforce, a custom controller is applied to overrule the embedded services of a regular controller.
To include new actions.
To develop visualforce pages that follows user permissions.
Customs controller classes are implemented in system mode.
Through the Keyword “ with sharing”, we can do field-level security, Role Hierarchy, etc.
Standard Controller
In salesforce, standard controllers are used to interacting with and access the structured business data present in the records.
Custom Controller
Custom controllers are used to developing customised functionalities and they can replace the available functionalities.
Controller Extension
In Salesforce, controller extensions are used to include or expand the services of a Custom controller or a standard controller.
Want to enhance your skills in dealing with the world's best CRM, enroll in our Salesforce Online Course. |
Several utility and system classes are available to develop custom controller logic. To create a custom controller class, we have to follow the below steps:
Public class EmailidListController {
Code
}
When you make any changes in the Apex, you have to save it.
Related article - Salesforce Guide |
<apex:page:controller=”EmailidListController”>
<apex:form>
< Apex: page block: Email Id List id =” Email Id_List”>
</apex:pageBlock>
</apex:form>
</apex:page>
Visualforce Markup uses the following Methods:
1. Action Methods
These methods are used to carry out navigation or logic when a page event happens, like a user clicking on a button, etc. Action methods are invoked through (!) notation.
2. Getter Methods
These methods are used to retrieve values from the controller. Each value determined by the controller and exhibited in a visual force page must have a getter method associated with it.
For example, in a controller apex class if we have a variable called “account”, then it should have a “getAccount” method associated with it to access it through (!) notation. Value argument present in the < Apex:inputField> tag applies this notation to use the account, and dot notation is used to exhibit the name of the account.
3. Setter Methods
These methods are used to send particular values to the controller. In the controller, setter methods are executed automatically before the action methods get executed. For
For example, if we want the markup to execute the search utility of leads on a page, then the corresponding controller integrates the setter and getter methods for the input of the search box.
After that, the controller uses the search text to send a SOSL Query, once the user presses GO. Markup implements the setter method before it executes the search action method.
In Salesforce, custom controllers are used to implementing the logic of the Visualforce pages. Custom controllers will have the methods to retrieve the data that is to be displayed on the visualforce page.
In the next topic, we will discuss in detail “Controller Extension in Salesforce”. Keep following us for more info on Salesforce Development/Programming.
Explore Salesforce Sample Resumes! Download & Edit, Get Noticed by Top Employers! |
Mindmajix offers different Salesforce certification training according to your desire with hands-on experience on Salesforce concepts
Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:
Name | Dates | |
---|---|---|
Salesforce Training | Dec 24 to Jan 08 | View Details |
Salesforce Training | Dec 28 to Jan 12 | View Details |
Salesforce Training | Dec 31 to Jan 15 | View Details |
Salesforce Training | Jan 04 to Jan 19 | View Details |
Arogyalokesh is a Technical Content Writer and manages content creation on various IT platforms at Mindmajix. He is dedicated to creating useful and engaging content on Salesforce, Blockchain, Docker, SQL Server, Tangle, Jira, and few other technologies. Get in touch with him on LinkedIn and Twitter.