What Is Standard Controller In Visualforce?

In Visualforce, a standard controller is a pre-built Apex controller provided by Salesforce that allows developers to work with standard database objects (such as records from Salesforce objects like Account, Contact, Opportunity, etc.) without having to write custom Apex code. Standard controllers provide basic CRUD (Create, Read, Update, Delete) operations and other standard functionality for interacting with these objects in Visualforce pages.

When using a standard controller in Visualforce, you can directly reference fields and perform operations like saving records without explicitly writing Apex code. Standard controllers also handle security and access permissions automatically, ensuring that users only have access to the records they are authorized to view or modify.

Here's a basic example of using a standard controller in Visualforce:

<apex:page standardController="Account">

    <apex:form>

        <apex:inputField value="{!Account.Name}"/>

        <apex:commandButton action="{!save}" value="Save"/>

    </apex:form>

</apex:page>


In this example, the <apex:page> tag specifies the standard controller for the Account object. The <apex:inputField> tag binds to the Name field of the Account object, allowing users to edit it directly on the Visualforce page. The <apex:commandButton> tag triggers the save action, which saves any changes made to the Account record.

Using standard controllers can significantly reduce development time and complexity when building Visualforce pages for interacting with Salesforce data.

Comments

Popular posts from this blog

Introduction to Salesforce Agent Script: Build Predictable AI Agents

Anti-Patterns in Salesforce Agentforce: What to Avoid When Building AI Agents

MCP vs. Traditional APIs: Choosing the Right Integration Approach