I am having some confusion while using PageMessages and Messages in my VF Pages. I'm using an apex controller to pass a message to my vf page but the problem is that if I use PageMessages then it showing the default validation error messages on that page. And if use Apex:messages then the error messages don't show up at all...
This component displays all messages that were generated for all components on the current page, presented using the Salesforce styling.
All messages that were generated for all components on the current page. If an
<apex:messages>component is not included in a page, most warning and error messages are only shown in the debug log.
This component supports HTML pass-through attributes using the "html-" prefix. Pass-through attributes are attached to the generated tag. (Each message is contained in a list item.)
Functionality is same for both these components. Way of display is different.
apex:pageMessages uses salesforce default styling. For
apex:messages we need to add custom style using
style attributes available. Here is detail on apex:pagemessages and apex:message.
apex:PageMessages is a containing component where any messages that have been added to the page will appear.
apex:pageMessage is a component that adds a single message to the page.
apex:message allows you to associate a message with a component
I've not used apex:messages - I can't see how it particularly differs from apex:pagemessages
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.
I'd start off adding an apex:pageMessages component to the top of your page and then add some messages in programmatically via the ApexPages methods - that should help clarify things.
You can refer folloing link : http://www.sfdcpoint.com/salesforce/apexpagemessage-and-apexpagemessages-salesforce/
apex:pageMessages is the component where you can add multiple messages and it shows all the errors with formatting i.e. It displays all the messages that were generated for all components on the current page with formatting.
apex:pageMessage is used to display single message i.e. it shows the specified message with formatting.
apex:messages is similar to
apex:pageMessages i.e. it shows all of the errors but with no formatting i.e. All messages that were generated for all components on the current page will be displayed without formatting.
apex:message shows only the error for the specified field i.e. it is used to display message for a specific component.