lut 242015

Salesforce – How to show different error messages in Apex / Visualforce?

When we build custom Visualforce page, there are times we want to send some error message to user saying that something went wrong or additional data is required. Other time we want just inform him, that process bas been successfully ended.

We can do this by showing different types Apex page message severities. To do this, just use one of the following:

Fatal

ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Fatal, 'ApexPages.Severity.FATAL'));

Error

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

Warning

ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Warning, 'ApexPages.Severity.WARNING'));

Confirmation

ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Confirm, 'ApexPages.Severity.CONFIRM'));

Informational

ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'ApexPages.Severity.INFO'));

and you will get one of these pretty images.

apex-messages

Tagged with , , , , , 0 komentarzy

Dodaj komentarz

Your email address will not be published. Please enter your name, email and a comment.