Adding Error Message in the Visualforce page through Apex controller.
Hi,
In this post i am giving an example of how to add error message in controller and display in VF Page.
Syntax : <apex:pageMessages ></apex:pageMessages>
Apex Controller:
public class ErrorMsgController {
public void DisplayError(){
Apexpages.addMessage( new ApexPages.Message (ApexPages.Severity.ERROR, 'Required fields are missing. ')); //FATAL, WARNING, INFO, CONFIRM
}
}
VF Page:
<apex:page sidebar="false" showHeader="false" controller="ErrorMsgController">
<apex:form >
<apex:pageMessages ></apex:pageMessages>
<apex:commandButton value="Click" action="{!DisplayError}"/>
</apex:form>
</apex:page>
Hi,
In this post i am giving an example of how to add error message in controller and display in VF Page.
Syntax : <apex:pageMessages ></apex:pageMessages>
Apex Controller:
public class ErrorMsgController {
public void DisplayError(){
Apexpages.addMessage( new ApexPages.Message (ApexPages.Severity.ERROR, 'Required fields are missing. ')); //FATAL, WARNING, INFO, CONFIRM
}
}
VF Page:
<apex:page sidebar="false" showHeader="false" controller="ErrorMsgController">
<apex:form >
<apex:pageMessages ></apex:pageMessages>
<apex:commandButton value="Click" action="{!DisplayError}"/>
</apex:form>
</apex:page>
1 comments:
how can we display the error in the at field level
Post a Comment