How to display error messages in the Visualforce page?

To display error messages in the Visualforce page add below tag where you want to display the error message.

Visualforce page:

<apex:pageMessages />

Apex Controller:
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error Message.');


ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Error Message.'));


1 comment:

  1. I've never used apex or visual force, can I use this error message at the top of the account page to display a value from an account text field?


Sharing is Caring!!! Share this with your friends!!!

submit to reddit