Monday, August 20, 2012

Difference In Between Apex PageMessage, PageMessages and Message VF Pages Tags in Salesforce

Most of the times on submission of page errors will be there and for showing those error messages different message tags are there in Visualforce Page Reference guide and first time they all are gave a feel that they all are same but some minor differences are there among them and those differences are as given below:-


Apex:PageMessages

apex:PageMessages is a containing component where any messages that have been added to the page will appear.

Apex:PageMessage
apex:pageMessage is a component that adds a single message to the page.

Apex:Message
apex:message allows you to associate a message with a component.


Notes

ApexPages.Message is the class that is used to model a message.  A message isn't associated with a page until it is added via the ApexPages class.

ApexPages is a class that allows you to access the current page (through ApexPages.CurrentPage()) and manage messages for the current page.


As Shown below messages can be of Error type and Custom Type and generally Apex:PageMessages tag comes in use for showing all  the messages.