Apex:pageMessage Tag :In our previous Salesforce Tutorial we have learned about <Apex:Tabpanel> tag and how it works when used in visualforce page.In this Salesforce Training Tutorial we are going to learn about Visualforce apex:pagemessage tag, what is apex:pagemessage tag, why we use apex:pagemessage tag in visualforce page.

Apex:pageMessage Tag

<apex:pagemessage> : apex:pagemessage tag is used to display message when any action or event is occurs.<apex:pagemessages/> tag must be used  to return the output of the page message. Depending up on the severity of the error message we use different message class. We use five message class they are

  • Confirm.
  • Error.
  • Fatal.
  • Info.
  • Warning.


  • <apex:pagemessage Summary=”validate error message!!” severity=”confirm”  strength=”3″/>
  • <apex:pagemessage Summary=”validate error message!!” severity=”Error”  strength=”3″/>
  • <apex:pagemessage Summary=”validate error message!!” severity=”Fatal”  strength=”3″/>
  • <apex:pagemessage Summary=”validate error message!!” severity=”Info”  strength=”3″/>
  • <apex:pagemessage Summary=”validate error message!!” severity=”Warning”  strength=”3″/>

Different attributes supported by apex:pageMessage Tag.


Let us see how apex:pagemessage tag works.

Create new visualforce page as shown below.


Click on Create Page apexpagemessage link.


Observe the code shown below.


In this Salesforce Tutorial we have written Visualforce page code to display error message when the closing date of the opportunity is not valid.If we enter  wrong date format it triggers error message as shown below. Depending up on the Severity the error message will be different.

Output: Apex:pageMessage  tag.


We have successfully tested how apex:pagemessage tag works in visualforce.