User Interface · Topic 3 of 4
Custom UI with Visualforce, Aura Components and Screen Flows
Choosing custom UI on Salesforce: Visualforce pages and controllers, extensions, StandardSetController, Aura components, and screen flows with custom LWCs.
- 4 min
- New components: LWC. Wizards: screen flows. PDFs and older pages: Visualforce.
- Standard controller, standard list controller, custom controller, controller extension.
- Extensions take the controller in their constructor; the leftmost extension wins.
What it is
Salesforce offers several ways to build custom user interfaces:
- Lightning Web Components: the default for new components.
- Aura components: the original Lightning component model, still used in older code and some containers.
- Visualforce: server-rendered pages with Apex controllers, the classic framework.
- Screen flows: declarative wizards, which can include custom Lightning Web Components.
The exam asks you to choose among them and to read Visualforce and controller code.
How it works
Choosing a UI technology
| Requirement | Best fit |
|---|---|
| New reusable component on a Lightning page | Lightning Web Component |
| Step-by-step wizard that admins can maintain | Screen flow, adding an LWC for a custom screen element |
| Render a page as PDF | Visualforce with renderAs="pdf" |
| Override a standard button in Classic or reuse an existing page | Visualforce |
| Existing Aura app or features an LWC cannot provide in that container | Aura component |
Visualforce controllers
| Controller type | Declared as | Use |
|---|---|---|
| Standard controller | standardController="Account" | Standard actions such as save, edit and delete for one record |
| Standard list controller | standardController="Account" recordSetVar="accs" | Lists and pagination of records |
| Custom controller | controller="MyController" | All logic in Apex; runs in system mode |
| Controller extension | extensions="ExtA,ExtB" | Adds or overrides actions while keeping a standard or custom controller |
<apex:page standardController="Opportunity" extensions="OppExtension">
<apex:form>
<apex:inputField value="{!Opportunity.Amount}"/>
<apex:commandButton action="{!save}" value="Save"/>
</apex:form>
</apex:page>
public with sharing class OppExtension {
private final Opportunity opp;
public OppExtension(ApexPages.StandardController std) {
this.opp = (Opportunity) std.getRecord();
}
}
An extension's constructor takes the controller as its only argument. When several extensions define the same method, the leftmost extension in the list wins, and extensions override the controller.
Visualforce limits and features
- View state holds the page's state between requests and is limited to 170 KB.
ApexPages.StandardSetControllerpaginates up to 10,000 records.readOnly="true"onapex:pageraises the query row limit for pages that make no DML.<apex:actionFunction>,rerenderand<apex:actionSupport>refresh parts of the page.- Visualforce can be used in Lightning Experience and wrapped in Lightning pages.
Aura components
| Aura piece | Role |
|---|---|
.cmp markup | Component template with aura:attribute |
| Client controller and helper (JavaScript) | Handle events and shared logic |
| Component and application events | Communication between components |
force:hasRecordId, flexipage:availableForAllPageTypes | Interfaces for record context and App Builder |
An Aura component can contain Lightning Web Components; an LWC cannot contain Aura.
Screen flows with custom components
A Lightning Web Component can be a screen component in a flow. Its meta file uses the target lightning__FlowScreen, and @api properties become inputs and outputs in Flow Builder. The component can block Next with a validate() method and move the flow with FlowNavigationNextEvent.
A worked example
Sales wants a printable quote document from an Opportunity with its line items. An LWC has no built-in way to render a page as PDF, but a Visualforce page can, with renderAs="pdf" and a standard controller on Opportunity plus an extension that loads the line items. A quick action or button opens it. For a multi-step discount request that admins maintain, a screen flow is the better choice.
If a requirement says "admins must be able to change the steps", the answer leans to a screen flow. If it says "reusable, rich, interactive component", choose LWC.
How the exam asks about this
- "Two extensions both define save(). Which runs?" The leftmost extension in the list.
- "Paginate thousands of records in Visualforce."
StandardSetController. - "Use a custom component inside a flow screen." An LWC with the
lightning__FlowScreentarget.
What to remember for the exam
- New components: LWC. Wizards: screen flows. PDFs and older pages: Visualforce.
- Standard controller, standard list controller, custom controller, controller extension.
- Extensions take the controller in their constructor; the leftmost extension wins.
- Custom controllers run in system mode; add
with sharingto enforce sharing. - View state is limited to 170 KB; StandardSetController holds up to 10,000 records.
A custom controller replaces the standard controller completely, so standard actions such as save must be written in Apex. To keep them, use an extension instead.
Common mistakes
Using a custom controller only to add one button. An extension keeps the standard actions.
Expecting an LWC to wrap an Aura component. Only Aura can contain LWC.
Storing large collections in Visualforce view state. Mark them transient or query them again.
Check yourself
What does a controller extension's constructor take?
The standard or custom controller, such as
ApexPages.StandardController.Which UI technology renders a page as PDF?
Visualforce, with
renderAs="pdf".How is an LWC made available as a flow screen component?
Expose it with the
lightning__FlowScreentarget in its meta XML file.
Topic 3 of 4 in User Interface
Test yourself on User Interface
The full Salesforce Platform Developer question bank has 645 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Salesforce. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.