Sample Code:
Visualforce page:
Apex Class:
Output:
Visualforce page:
- <apex:page controller="Sample">
- <apex:form >
- <apex:pageBlock >
- <apex:pageMessages />
- Testing Page Message
- <apex:pageBlockButtons location="bottom">
- <apex:commandButton value="Call" action="{!check}"/>
- </apex:pageBlockButtons>
- </apex:pageBlock>
- </apex:form>
- </apex:page>
Apex Class:
- public class Sample {
- public Sample() {
- }
- public void check() {
- ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Check button is clicked'));
- }
- }
Output:
Wonderful .! It was simple and easy to understand.
ReplyDeleteCan you please also tell how to differentiate between success and error message in Visual force page.
Check this for other Serverities - http://www.infallibletechie.com/2013/07/apexpagesseverity-supported-values.html
Delete