fbpx

Free Salesforce Developers Tutorials >

Chapter 15 - Visualforce >

Apex Page Message in Visualforce

Apex Page Message in Visualforce

What You’ll Learn


S2 Labs

Display Message On Visualforce

Whenever we want to display a message on a page, we can use a <apex:pageMessage> tag. Here below is the example code:

<apex:page controller="MyController">
     <apex:pageMessage severity="Error" summary="First
Error message on page" strength="1"></apex:pageMessage>
     <apex:pageMessage severity="Error" detail="Second Error message on page" strength="2"></apex:pageMessage>
     <apex:pageMessages ></apex:pageMessages>

</apex:page>

Here is the example of controller which can be defined to add message to the page:

public class theController {
      public theController(){
             ApexPages.addmessage(new ApexPages.message( ApexPages.severity.Error, 'First Error Message added from apex'));
             ApexPages.addmessage(new ApexPages.message( ApexPages.severity.Error, 'Second Error Message added from apex'));
     }
}

salesforce-developer

Download Study Material

Get access to exclusive study material for Salesforce Certification and ace your exams!

Download Now

Our Salesforce Certification Courses

Hey there! Glad you made it through our Salesforce Developer Training for beginners . But wait! We've got some high-in-demand Salesforce courses for you to take your Salesforce skills to the next level, making you a desired professional in the Salesforce job market.

Post a Comment

Your email address will not be published. Required fields are marked *