Curriculum
Page Navigation in Visualforce refers to the process of moving users from one page to another within a Salesforce application. Navigation plays a critical role in user experience because it helps users access information, complete tasks, move through workflows, and interact with different parts of an application efficiently.
Visualforce provides several navigation mechanisms including hyperlinks, command links, command buttons, PageReference objects, URL parameters, redirects, and dynamic navigation through Apex controllers.
Understanding Page Navigation is essential for Salesforce Developers because every enterprise application requires smooth and intuitive movement between pages, records, forms, dashboards, and business processes.
Page Navigation allows users to move between pages and application sections.
Navigation can be used for:
Good navigation improves user productivity.
Without navigation:
Application Pages
↓
Isolated Screens
↓
Poor User Experience
With navigation:
Connected Pages
↓
Smooth Workflow
↓
Better Productivity
Navigation creates a complete application experience.
Guide users efficiently.
Reduce unnecessary clicks.
Enable business processes.
Provide easy access to information.
Connect multiple modules.
These benefits make navigation essential.
Visualforce supports multiple navigation methods.
Each method serves different purposes.
A hyperlink directs users to another page.
Example:
<a href="/apex/HomePage">
Home
</a>
When clicked:
Navigate to HomePage
Hyperlinks are simple and effective.
Example:
<apex:outputLink
value="/apex/CoursePage">
Courses
</apex:outputLink>
Output:
Courses
Users can navigate to the Course page.
Command Links execute Apex actions before navigation.
Example:
<apex:commandLink
value="View Details"
action="{!showDetails}"/>
The controller method executes first.
User Clicks Link
↓
Controller Executes
↓
Navigation Occurs
This supports dynamic navigation.
A button that can perform actions and navigation.
Example:
<apex:commandButton
value="Next Page"
action="{!goToNextPage}"/>
Useful for forms and workflows.
PageReference is an Apex object used for navigation.
Example:
PageReference page;
It specifies which page should open next.
Example:
public PageReference
goToHome(){
PageReference page =
Page.HomePage;
return page;
}
The user is redirected to HomePage.
Suppose a Visualforce page exists:
StudentPortal
Controller:
public PageReference
openPortal(){
return
Page.StudentPortal;
}
Navigation occurs dynamically.
Redirect forces the browser to load a new page.
Example:
PageReference page =
Page.HomePage;
page.setRedirect(
true
);
return page;
The browser performs a complete page reload.
| Feature | Redirect | Non-Redirect |
|---|---|---|
| Browser Reload | Yes | No |
| URL Updated | Yes | No |
| New Request | Yes | No |
Developers choose based on requirements.
Parameters pass information between pages.
Example:
/apex/StudentPage?id=001
The page receives record information.
Controller:
PageReference page =
Page.StudentPage;
page.getParameters()
.put(
'id',
studentId
);
Parameters are attached dynamically.
Example:
String recordId =
ApexPages
.currentPage()
.getParameters()
.get('id');
The page retrieves the value.
Example:
PageReference page =
new PageReference(
'/' + accountId
);
The user is redirected to a Salesforce record.
Visualforce can redirect users externally.
Example:
PageReference page =
new PageReference(
'https://example.com'
);
return page;
External navigation is supported.
Navigation based on business conditions.
Example:
if(
studentType ==
'Premium'
){
}
Different users may see different pages.
public PageReference
navigate(){
if(isAdmin){
return
Page.AdminDashboard;
}
return
Page.StudentDashboard;
}
Navigation changes based on user roles.
Example:
public PageReference
saveStudent(){
insert student;
return
Page.SuccessPage;
}
After saving:
Success Page Opens
This is a common workflow.
Breadcrumbs display user location.
Example:
Home
>
Students
>
Details
Users can navigate easily.
Example:
Home
Students
Courses
Reports
Menus improve usability.
Home Page
↓
Student Registration
↓
Save Student
↓
Success Page
↓
Dashboard
This represents a common business workflow.
A software training institute requires:
Page Navigation connects all modules into a complete application.
This improves user productivity.
These practices improve usability.
Developers should avoid these issues.
These advantages enhance application quality.
Developers should:
Security remains important.
Understanding Page Navigation helps professionals:
Navigation is a core Visualforce development skill.
Page Navigation enables users to move efficiently between Visualforce pages, records, forms, and business processes. Through hyperlinks, command links, command buttons, PageReference objects, URL parameters, redirects, and dynamic navigation, developers can create seamless application workflows and improve user experience. Mastering Page Navigation is essential for building professional and enterprise-ready Salesforce applications.
Page Navigation allows users to move between Visualforce pages and application sections.
PageReference is an Apex object used to navigate to another page.
Redirect creates a new browser request, while non-redirect navigation does not.
Yes. Parameters can be attached using the getParameters() method.
Yes. PageReference can open record detail pages.
Navigation improves user experience, productivity, and workflow efficiency.
Looking to learn more technologies and programming skills?
Send us your inquiry and start your journey towards a successful IT career.
✔ 100% Secure ✔ No Spam ✔ Instant Response
WhatsApp us