Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Visualforce relates to questions where the Visualforce language or framework are concerned. This is primarily VF pages, components, PDF rendering, and email templates. This would only cross-over to Lightning where Lightning Out (Lightning for VF) or VF pages using SLDS or being used in LEX. Where a question relates to Apex invoked as part of a VF page, this tag would also be appropriate.

Visualforce is a framework that allows developers to build sophisticated, custom user interfaces that can be hosted natively on the Force.com platform. The Visualforce framework includes a tag-based markup language, similar to HTML.

Developers can use Visualforce to create a Visualforce page definition. A page definition consists of two primary elements:

  • Visualforce markup
  • A Visualforce controller

Visualforce Markup
Visualforce markup consists of Visualforce tags, HTML, JavaScript, or any other Web-enabled code embedded within a single tag. The markup defines the user interface components that should be included on the page, and the way they should appear.

Visualforce Controllers
A Visualforce controller is a set of instructions that specify what happens when a user interacts with the components specified in associated Visualforce markup, such as when a user clicks a button or link. Controllers also provide access to the data that should be displayed in a page, and can modify component behavior. A Visualforce controller is always written in Apex.

Architecture Visualforce is a server-side compiled web user interface technology. In that, much of what is written as Visualforce markup will get compiled and rendered into HTML on the server and sent to the client as an HTML document. Take for instance the following:

<apex:outputPanel layout="block">{!someField}</apex:outputPane>

When Visualforce receives this code, it attempts to compile it. It will perform reference checks on the server to ensure that the referenced someField binding is valid given the current state of metadata in the Salesforce environment. This reference will be remembered to ensure that no change can be made to the name of someField that might break the page. Once the reference check is successful, the page is stored as metadata and markup.

At runtime the same page will be requested. Before it can be sent to the client, it will be rendered into HTML. So the above markup would end up turning the Visualforce markup into browser-compliant HTML while resolving any data bindings into text. If the value of someField at the time of the page request was 'My Text Value' then what you would get served to the browser would be:

<span>My Text Value</span>

This server-side compilation, rendering, and data resolution is one of the key differences between Visualforce and the newer Lightning Component Framework, as Lightning Components are client rendered.

Useful Documentation

history | excerpt history

Code Language (used for syntax highlighting): lang-xml