apex:pageMessage Component
The apex:pageMessage
component in Visualforce is used to display success messages, error messages, and warning messages to users.
Syntax
The apex:pageMessage
component has the following syntax:
<apex:pageMessage strength="string" title="string" severity="string" summary="string" />
Example
To display a success message on a Visualforce page, use the following code:
<apex:pageMessage strength="success" title="Success!" summary="The record has been saved successfully." />
This will display a success message with a title "Success!" and a summary "The record has been saved successfully." on the Visualforce page.
Explanation
The apex:pageMessage
component is used to display messages to users. The strength
attribute is used to set the type of message, which can be success, info, warning, or error. The title
attribute is used to set the title of the message. The summary
attribute is used to set the content of the message, and the severity
attribute can be used to set the severity of the message.
Use
The apex:pageMessage
component is used to display messages to users on a Visualforce page. Use this component to provide feedback to users about the status of their actions. For example, you can display a success message when a record is saved successfully, or an error message when there is an issue with the data entered by the user.
Important Points
- The
apex:pageMessage
component should be used only once per page. - The
severity
attribute is not used in the latest version of Salesforce, and is instead replaced by thestrength
attribute. - The
strength
attribute is used to set the strength of the message, which can be success, info, warning, or error. - The
title
andsummary
attributes are required.
Summary
The apex:pageMessage
component in Visualforce is used to display success messages, error messages, and warning messages to users. Use this component to provide feedback to users about the status of their actions. The strength
, title
, and summary
attributes are required, and the severity
attribute is not used in the latest version of Salesforce. This component should be used only once per page.