Monday, August 11, 2014

13) 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(myMsg);

(OR)

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

No comments: