Your Page Title
🔍

    Understanding Component in Visualforce

    The <apex:page> component is the foundation of every Visualforce page. It’s the root tag that defines a Visualforce page and controls key aspects like layout, controller reference, and page behavior.


    Syntax

    xmlCopyEdit<apex:page>
        <!-- Page content goes here -->
    </apex:page>
    

    Common Attributes

    AttributeDescription
    controllerSpecifies a custom Apex controller
    recordSetVarUsed for list controllers
    standardControllerTies the page to a Salesforce standard object like Account, Contact
    showHeaderShows/hides Salesforce standard header (true/false)
    sidebarShows/hides sidebar (true/false)
    titleCustom title for the page

    Example 1: Basic Page

    xmlCopyEdit<apex:page>
        <h1>Welcome to Salesforce Visualforce!</h1>
    </apex:page>
    

    Example 2: With Standard Controller

    xmlCopyEdit<apex:page standardController="Account">
        <h1>Account Name: {!Account.Name}</h1>
    </apex:page>
    

    Example 3: With Custom Controller

    xmlCopyEdit<apex:page controller="MyController">
        <h1>Hello, {!name}</h1>
    </apex:page>
    

    When to Use <apex:page>

    • Always – It’s the container for all other Visualforce components.
    • It defines how the page connects with Apex logic or standard Salesforce records.

    Best Practices

    • Always set showHeader="false" and sidebar="false" for public/embedded pages.
    • Use title to help with page SEO and browser tabs.
    • Minimize logic in the page — keep business logic in controllers.