Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

Adding Error Message in the Visualforce page through Apex controller

Be First!

Adding Error Message in the Visualforce page through Apex controller

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>

 

(1364)

Previous
Next

Leave a Reply