Apex · Salesforce

APEX CUSTOM CONTROLLER

Custom controller :

A custom controller is a class written in Apex that implements all of a page’s logic, without leveraging a standard controller. If you use a custom controller, you can define new navigation elements or behaviors, but you must also reimplement any functionality that was already provided in a standard controller. Like other Apex classes, custom controllers execute entirely in system mode, in which the object and field-level permissions of the current user are ignored. You can specify whether a user can execute methods in a custom controller based on the user’s profile.

What is custom controller? why we go for custom controllers?

Standard controllers provides only built in standard functionality to visualforce pages, such as Save, Edit, Cancel & Delete etc….

We cannot customize/develop our own functionality by using standard controllers. By using custom controllers we can write our own functionality or override existing functionality. Custom controller is an Apex Class developed by us. See the below syntax to define custom controller in visualforce page.

When Custom Controller in Salesforce is used?

  • Custom Controller in Salesforce is used to override the built in functionalities of a standard controller.
  • To add new actions.
  • To build visualforce pages that respects user permissions.
  • Custom controller and Controller extensions classes executes in system mode.
  • User Permissions, field level security, Organization wide defaults, Role hierarchy and Sharing rules can be done using keyword called with sharing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s