Latest Updates

Travel to Technology

Dayton Metro Library

How to Display Error/Information messages in Visualforce Pages

Learn How to Show Error/Information Message in Visualforce Page

Many case user want to display multiple error/warning/information message in the UI(Visualforce Page). Please find below sample code

Apex Code :

ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.Info, 'Please fill all manfaroty fields.'));
ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.Error, 'Name is manfatory.'));
ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.WARNING, 'Need more information in order to process your file.'));

Visualforce Page:

<apex:pageMessages>

Note : you can use this logic for debugging code also