Get Started with VisualForce Controllers in Salesforce

Get Started with VisualForce Controllers in Salesforce

Salesforce, the market leader in CRM space, provides a web development framework called VisualForce that enables developers to build sophisticated, dynamic, and custom user interfaces that can be hosted natively on the platform. It is a component-based user interface (UI) framework comprises of a tag-based markup language and a set of server-side controllers that are designed to simplify the development and deployment of cloud applications and websites.

VisualForce Page

With the powerful set of tags resolved at the server-side, the VisualForce framework is also known as a page-centric web application model. VisualForce uses a markup language similar to HTML for designing pages and Apex code for handling database operations.

Let us take a look at the classification of VisualForce pages:

VisualForce Pages: A markup language like HTML is used for designing the layout of pages.

Custom Controller: Apex code is used to handle backend processing (server-side operations) implemented at the VF page.

JavaScript: JavaScript helps in managing client-side processing and can be coupled with CSS for a revamp of the interface.

Apex Extensions: Logical operations can be performed using Apex extensions which are not available in standard controllers.

Few points to remember 

  1. VisualForce Page has many page blocks.
  2. One Page Block has many Page Block Sections.
  3. One VisualForce Page has many tags.
  4. The tag has many attributes.

VisualForce Controllers

VisualForce Controller is the second type element in VisualForce pages which has a set of instructions to manipulate data and schema with user interactions. Controllers provide Data and Logic to the users.

How a Controller is used in VisualForce pages?

  • Controllers provide business logic to VisualForce pages.
  • It accepts data from users like input values.
  • The controller manipulates the user’s input and performs an action on behalf of the user.
  • Manipulated User’s data is redirected to the browser as a new page.

Three Types of VisualForce Controllers

Standard Controllers – Standard controllers are the default Controller’s provided by These standard controllers will have the same logic and functionality used standard VisualForce pages. No Apex code is required in Standard Controllers.

Syntax :-

Custom controller –  When a developer requires different logic and functionality he/she may write their own Apex controller class. Custom controllers will not provide default functions like standard controllers. Custom apex code must be written for custom controllers.

Syntax :-

Controller extensions AKA Extensions – If we want to use both custom controller functionality and standard controller functionality, we have to use extension controllers. Extension Controllers begin with Standard controller and extended or overridden with the custom controller with custom apex code.

Syntax :-

Example of VisualForce Page

To create a VisualForce page, log in to your org then go to setup -> Developer Console. Then inside developer console, click File -> New -> VisualForce Page. Below code is an example of a  VisualForce page that uses a standard list controller Account to show the account list on the VisualForce page:


A VisualForce page is created with HTML components, controllers, and a few style elements on the platform. Just like Hypertext Markup Language (HTML), VisualForce can be integrated with any JavaScript framework, database, or web technology to develop a high-quality and effective user interface. 

A Visualforce Controller represents the complete instruction set that defines what can happen when the user interacts with different components on VisualForce pages.

Leave a Reply