Experience Salesforce
Apex Page Message in Visualforce
What You’ll Learn
- Display Message On Visualforce
Topics
- What is Visualforce in Salesforce?
- Architecture of Visualforce Page
- Standard Controller in Visualforce
- How to create View Page in Visualforce?
- How To Create Edit Page In Visualforce?
- Custom Controller in Salesforce
- Getter, Setter Method Part 1
- Getter, Setter Method Part 2
- Apex Page Message in Visualforce
- Controller Extensions Part 1
- Controller Extensions Part 2
- Using Controller Extension with Custom Controller
- Order of Execution
- Tabs in Visualforce
- System Mode in Visualforce
Display Message On Visualforce
Whenever we want to display a message on a page, we can use a <
tag. Here below is the example code:apex:pageMessage>
<apex:page controller="MyController">
<apex:pageMessage severity="Error" summary="First
Error message on page" strength="1"></apex:pageMessage>
<apex:pageMessage severity="Error" detail="Second Error message on page" strength="2"></apex:pageMessage>
<apex:pageMessages ></apex:pageMessages>
</apex:page>
Here is the example of controller which can be defined to add message to the page:
public class theController {
public theController(){
ApexPages.addmessage(new ApexPages.message( ApexPages.severity.Error, 'First Error Message added from apex'));
ApexPages.addmessage(new ApexPages.message( ApexPages.severity.Error, 'Second Error Message added from apex'));
}
}
Need Extra Support? Our FREE study materials have got you covered.
Our expert-prepared study materials provide the answers you need. Clear your doubts and improve your skills with detailed notes from industry professionals.