Salesforce provides tools for creating user interfaces to manage and interact with data. These tools range from classic Visualforce pages to the modern Lightning Web Components (LWC) framework.
What is Visualforce?
<apex> markup language, similar to HTML, and integrates tightly with Salesforce’s backend.Visualforce pages are constructed using <apex> tags.
<apex:page>:
The root tag for a Visualforce page.
Example:
<apex:page>
<h1>Welcome to Salesforce</h1>
</apex:page>
<apex:form>:
Used to create forms for user input.
Example:
<apex:page>
<apex:form>
<apex:inputText value="{!name}" label="Enter Name"/>
<apex:commandButton value="Submit" action="{!submitName}"/>
</apex:form>
</apex:page>
<apex:inputText>:
Visualforce can use Apex classes to add dynamic behavior and logic to pages.
What are Custom Controllers?
Example: Visualforce Page:
<apex:page controller="MyController">
<h1>Hello, {!name}!</h1>
<apex:form>
<apex:inputText value="{!name}" />
<apex:commandButton value="Greet Me" action="{!greet}"/>
</apex:form>
</apex:page>
Custom Controller (Apex Class):
public class MyController {
public String name { get; set; }
public void greet() {
System.debug('Greeting ' + name);
}
}
Key Features of Visualforce:
What is LWC?
Web Standards:
Seamless Salesforce Integration:
Reusable Components:
Let’s create a simple LWC component with a button that logs a message when clicked.
HTML Template:
The structure of the component is defined using an HTML template:
<template>
<lightning-card>
<lightning-button label="Click Me" onclick={handleClick}></lightning-button>
</lightning-card>
</template>
JavaScript File:
The behavior of the component is controlled using JavaScript:
import { LightningElement } from 'lwc';
export default class Example extends LightningElement {
handleClick() {
console.log('Button clicked');
}
}
CSS File (Optional):
Deploying the Component:
Reduce Server Calls:
Use Lightning Data Service (LDS):
Efficient Component Design:
@wire decorators for efficient data fetching.Although Lightning Web Components (LWC) are the modern standard for Salesforce development, Aura Components (introduced in 2014) are still supported and used in specific use cases, such as Experience Cloud (Community) pages and legacy Lightning components.
.cmp, .controller, .helper) for defining structure, logic, and helper functions.| Feature | Aura Components | Lightning Web Components (LWC) |
|---|---|---|
| Performance | Slower due to framework overhead | Faster due to native browser support |
| Technology Base | Salesforce-specific framework | Standard web technologies (HTML, JS, CSS) |
| Code Complexity | Requires multiple files: .cmp, .controller, .helper |
More streamlined code in a single JS module |
| Data Access | Requires @AuraEnabled methods in Apex |
Uses @wire and Lightning Data Service (LDS) |
| Future Development | No longer recommended for new projects | Preferred for all new development |
"Why does Salesforce recommend using LWC instead of Aura Components?"
Your existing Visualforce explanation is good, but it lacks details about Standard Controllers, which are often tested in the exam.
The following Visualforce page displays an Account record without requiring an Apex controller:
<apex:page standardController="Account">
<h1>{!Account.Name}</h1>
<apex:detail subject="{!Account}" />
</apex:page>
standardController="Account" binds the page to the Account object.{!Account.Name} dynamically retrieves the account’s name.<apex:detail> renders a standard record detail view.| Use Case | Standard Controller | Custom Controller |
|---|---|---|
| Read and display object data | Yes | Yes |
| Use built-in Salesforce logic | Yes | No |
| Execute custom logic and SOQL queries | No | Yes |
| Handle complex user interactions | No | Yes |
"When should you use a Standard Controller instead of a Custom Controller?"
Your explanation of Dynamic Forms is great, but it lacks details on Lightning Record Pages and Lightning App Builder, which are commonly tested topics.
"How can you add an LWC to a Lightning Page?"
Your LWC explanation is good, but it is missing data access methods, particularly @wire and Apex calls.
LWC can retrieve Salesforce data in three ways:
lightning-record-form and lightning-record-view-form (no Apex needed).@wire to Query Account Dataimport { LightningElement, wire } from 'lwc';
import getAccounts from '@salesforce/apex/AccountController.getAccounts';
export default class AccountList extends LightningElement {
@wire(getAccounts) accounts;
}
@wire(getAccounts) accounts; – Reactively fetches accounts from an Apex method.import { LightningElement, track } from 'lwc';
import getAccounts from '@salesforce/apex/AccountController.getAccounts';
export default class AccountList extends LightningElement {
@track accounts = [];
handleLoadAccounts() {
getAccounts()
.then(result => {
this.accounts = result;
})
.catch(error => {
console.error(error);
});
}
}
"What is the best way to retrieve Apex data in LWC?"
@wire for reactive data binding or Imperative Apex Calls for user-triggered fetches.What is the main difference between Lightning Web Components (LWC) and Aura components?
Lightning Web Components use modern web standards, while Aura components rely on Salesforce’s proprietary framework.
Lightning Web Components are built using standard technologies such as JavaScript, HTML, and modern browser APIs. This makes them faster, easier to maintain, and more aligned with modern web development practices.
Aura components were Salesforce’s earlier component framework and rely on a proprietary event model and syntax. While Aura components still work and are supported, Salesforce recommends using LWC for new development whenever possible.
LWC also provides better performance because it runs natively in the browser rather than relying heavily on the Salesforce framework. However, some legacy features still require Aura, which is why developers may occasionally use both frameworks together.
Understanding when to use LWC versus Aura is a common topic in PDI exam questions.
Demand Score: 88
Exam Relevance Score: 90
How do Lightning Web Components pass data from a parent component to a child component?
Data is passed using public properties decorated with @api.
In Lightning Web Components, parent-to-child communication is achieved through public properties. The child component defines a property using the @api decorator, which allows the parent component to assign a value to that property.
For example, the parent component can include the child component in its HTML template and pass values through attributes. The child component receives the value through the @api property and can use it within its logic or UI.
This approach follows standard web component architecture where parent components control the data passed to children. Developers must ensure that the property is explicitly exposed using @api, otherwise it cannot be accessed externally.
Understanding component communication is essential for building modular Lightning applications and is frequently discussed in developer forums.
Demand Score: 86
Exam Relevance Score: 89
How can a child Lightning Web Component communicate with its parent component?
A child component communicates with its parent by dispatching custom events.
In Lightning Web Components, communication from child to parent occurs through events. The child component creates and dispatches a custom event using the CustomEvent class.
The parent component listens for this event in its template and handles it using an event handler method. When the event is triggered, the parent component can read the event details and respond accordingly.
This event-driven communication model helps maintain loose coupling between components and follows standard web component design principles. It also improves component reusability because child components do not directly depend on their parent components.
Understanding event communication patterns is essential when building complex Lightning applications involving multiple interactive components.
Demand Score: 84
Exam Relevance Score: 88
When should a developer use Lightning Data Service instead of Apex?
Lightning Data Service should be used when performing standard CRUD operations on Salesforce records without complex logic.
Lightning Data Service provides a simple way for Lightning components to interact with Salesforce records without writing Apex code. It automatically handles operations such as create, read, update, and delete while also managing data caching and security enforcement.
Using Lightning Data Service reduces the need for custom server-side code and improves performance because it minimizes unnecessary server calls. It also ensures that field-level security and sharing rules are respected automatically.
Developers should use Apex only when business logic becomes complex or when operations involve multiple objects or external integrations. Using Lightning Data Service whenever possible aligns with Salesforce’s best practice of minimizing custom code.
Demand Score: 80
Exam Relevance Score: 87
When is Visualforce still used in Salesforce development?
Visualforce is mainly used for legacy applications or when generating custom PDF documents and specialized page layouts.
Visualforce was the original Salesforce UI framework used before Lightning Experience. Although modern development now focuses on Lightning Web Components, Visualforce still exists in many older Salesforce implementations.
Developers may continue using Visualforce when maintaining legacy systems or building features not easily supported by Lightning components. One common example is generating custom PDF documents, such as invoices or reports, using Visualforce pages rendered as PDFs.
While Visualforce remains supported, Salesforce recommends building new interfaces using Lightning Web Components whenever possible to take advantage of better performance and modern web standards.
Demand Score: 78
Exam Relevance Score: 84