Standard Controller In Salesforce

  • (4.0)
  • | 2044 Ratings
Standard Controller In Salesforce

Architecture Of Salesforce:

We can write our VIEW pages with SFDC Visualforce. Visualforce pages are like JSP pages, and each page is associated with a controller we can make use to build standard controllers which already exist and can write our own controllers using APEX language. APEX is similar to JAVA and by using APEX we can write Model Classes as well.

Visualforce uses traditional model-view-controller(MVC) paradigm with an option for auto-generating controllers for DB Objects, by providing tight and simple integration along the DB. We can write our own controllers and extensions to controllers with the help of APEX code. It also provides AJAX components and embeds formula expression language for action, component binding interaction. The flexibility and assurance of safe data provided by result in nonparallel development capabilities to the developer.

MVC pattern contains below three modules:

  • Model
  • View
  • Controller

Model: Model is defined as what schema and data do salesforce use to represent the system completely. In Salesforce, we can say that sObjects are the model as every entity in salesforce is mapped to some sObject. (Objects, Fields, Relationships, etc)

View: How the schema and data are represented is termed as view. Visualforce is used to present the data to users. (Visualforce Page, Page Layouts, etc.)

Controller: Controllers are used to performing the actions whenever users interact with visual force. (APEX Classes, Triggers, etc.)

What is Visualforce Page?

  • A proprietary web development language created by
  • Synta for language is like HTML.
  • Fits into the "View" level of MVC.
  • Allows developers to build custom web pages.
  • Not intended for pure custom website creation, only useful internal to Salesforce.
  • Strength: It allows developers to easily create a complete custom page that has the exact look and feel like a standard Salesforce page
  • A basic level of web design or web development skillset is required to create a VF page.


  • Basics of HTML code.
    • HTML code is used for creating websites.
    • Every HTMl document begins with and ends with .
    • The visible part of the HTML Document is between and

Checkout SalesForce Tutorial

Eg of HTML Page Code:

		<h1>My First Heading</h1>
		<b>My First Paragraph</b>
		<u>My First Underline</u>

Regularly used Tags in Salesforce Visualforce Page: The below-mentioned Tags are regularly used in Salesforce for Visualforce Page Building.

  • Apex:Page,
  • Apex:PageBlock,
  • Apex:PageBlockSection,
  • Apex:Form.

How to create Visualforce Page in Salesforce?

Step to Create Visualforce Page:

Log in to Salesforce → Setup → Build → Develop → Visualforce Pages(Click on it) → Click on New button.


CSRF -- Cross-site reference forgery protection which helps & protects the page from Hacking protocols.

Default Visualforce page contains - Boilerplate Code.

Commenting in Visualforce Page is like --

Note: It’s hard to imagine a Trigger without APEX Class, which gives logic to trigger. On the same note, it’s hard to imagine a VFP in the real-time process without a controller.

  • APEX Class gives “Logic” to Triggers.
  • Controller gives “Logic” + “Data” to VFP.

Controllers :

Controllers are helpful to provide data and business logic to Visualforce Page. As the Visualforce Pages are “Dumb”, they are not operative and can show whatever you tell as they have no thinking capability.

We have 3 types of controllers:

  1. Standard controllers.
  2. Custom controllers.
  3. Controller extensions AKA Extensions.

Controllers give us:

  • Data.
  • Logic.

Standard Controller:

Standard Controller Code For Visualforce Page:

<apex:page standardController= "Account">
        <apex:pageBlock title="My Content">
            <apex:commandButton action="{!save}" value="Save Me"/>
        <apex:pageBlockSection title="My Content Section" columns= "2">
            <apex:inputField value = "{!}"/>
            <apex:inputField value = "{!Account.fax}"/>
            <apex:inputField value = "{!}"/>
            <apex:inputField value = "{!Account.accountNumber}"/>
            <apex:inputField value = "{!Account.industry}"/>



Important point To Remember:

  • 1 Visualforce Page has many page blocks.
  • 1 Page Block has many Page Block Sections.
  • 1 Visualforce Page has many tags.
  • 1 The tag has many attributes.

Checkout Salesforce Interview Questions

Explanation of Code:

<apex: page StandardController=” account”> → The bolded part of code defines the Attribute.

<apex:page> → Tag Name → To show on the screen.

StandardController=”Account” → Attribute Name → To show on the screen.

<apex:commandButton action="{!save}" value="Save Me"/> → Code for “Save Me” Button.

<apex:pageBlockSection title="My Content Section" columns= "2"> → For Page Block Section.

<apex:inputField value = "{!}"/> → For Input Field.

In the next topic, we will discuss in detail about “custom Controller In Salesforce”. Keep following us for more info on Salesforce Development/Programming.

Explore Salesforce Sample Resumes! Download & Edit, Get Noticed by Top Employers!Download Now!

Mindmajix offers different Salesforce certification training according to your desire with hands-on experience on Salesforce concepts

Subscribe For Free Demo

Free Demo for Corporate & Online Trainings.

About The Author

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. Protection Status