Visualforce Basics

Visualforce Basics | Salesforce Learning Guide

Visualforce is a powerful tool and a stimulating framework allowing developers to explain the interface component and to create sophisticated custom interfaces which will be hosted natively on the lightning platform The Visualforce framework consists of two elements: a tag-based markup and a set of server-side controllers making it easier for developers to perform database operations

That is, components are defined using the markup language on the page and bind it to the controller (Standard or custom) to perform logical operations on the components.

The server hosts the visual force, so whenever any Visualforce code is written it will be generated and will be run on the servers.

Controllers and Extensions

  • Salesforce has provided the basic building functionality to be followed and used with appropriate logic for a Standard controller that works for a standard page as set by Salesforce. 

Syntax: <apex:page standardController="Contact">

For example, if we are going to use the standard Obj Opportunity, then we need to use a standard controller, clicking on the Save button on that Visualforce page will result in the same behaviour as clicking Save on a standard Opportunity edit page. A Standard list controller: Visualforce pages as the name suggests that can display the records in a list manner or act on a list of records. Examples of already present Salesforce pages that work with sets of records include list pages, related lists, and mass action pages.

dont miss out iconDon't forget to check out: Salesforce Lightning Component Inside Lightning Web Component Using Visualforce Page

Example code:

<apex:page standardController="Contact" recordSetVar="contacts">
    <apex:pageBlock title="Contacts List">
        <!-- Contacts List example of Standard List Controller -->
        <apex:pageBlockTable value="{! contacts }" var="ct">
            <apex:column value="{! ct.FirstName }"/>
            <apex:column value="{! ct.LastName }"/>
            <apex:column value="{! ct.Email }"/>
            <apex:column value="{! ct.Account.Name }"/>


contact list
  • A Custom controller can be defined as a class written in Apex that provides the functionality of all of the page’s logic and behaviour without leveraging a typical standard controller. Access for the custom controller is embedded in the VF page as <apex:page controller="ContactsListWithController">  Custom controller, you'll define new navigation elements or behaviours, but you want to also reimplement any functionality that was already provided during a standard controller.

dont miss out iconCheck out another amazing blog by Narendra here: Understanding Accounts & Contacts for Sales Process | Salesforce Guide


<apex:page controller="ContactsListWithController">
        <apex:pageBlock title="Contacts List" id="contacts_list">
<!--Example of custom controller-->
            <!-- Contacts List goes here -->
Custom Controller Apex Class
public class ContactsListWithController {
    // Controller code goes here



Popular Salesforce Blogs