apex:pagemessage component will generate and displays all error messages of all components on the current page, presented using the SF styling. This component will have some attributes that to be used when apex:pagemessage component is used in Visualforce page.
apex:pagemessage component Attributes
Title | Title will display the title name for the Error. |
Summary | This attribute prints the summary of the title Error
Message. |
Detail | This will print the detail description of the Error. |
Severity | This attribute is a logo type of the Error. We can select the
Error severity types as Error, Warning, Info and Confirm. |
Strength | This size of the severity message logo ranges from 1 to 3 |
Rendered | This attributes defined whether the component should be
displayed or not.
|
Escape |
Its Boolean type, A Boolean value whether, sensitive HTML, and XML characters should be escaped in the HTML old generated by this component.
|
Show Detail | It’s a Boolean type, specifies whether it displays the detail position of the messages, by default its false |
Visualforce Page
<apex:page>
<apex:pageMessage summary="This pageMessage will always display. Validation error
messages appear in the pageMessages component."
severity="warning" strength="3" />
<apex:pageMessages />
</apex:page>
In above Visualforce page, We have added apex:pagemessage component and we have added some attributes like Summary, Severity and Strength of the Error message. We have add /> and <apex:pageMessages> components as end tag if not it shows error like Element type “apex:pagemessage” must be followed by either attribute specifications, “>” or “/>”.
Output
Conclusion : In this Salesforce tutorial, we have learned about apex:pagemessage component and how it will helpful in visualforce pages. In our upcoming Salesforce tutorial, we will learn about apex:pageblock component.