You need to sign in to do that
Don't have an account?
prasad1.3969574005596787E12
How to display message in apex
Hi All,
As I am trying to Display message in the apex code:
for if condition is true
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,cw.cat.name));
As I am trying to Display message in the apex code:
for if condition is true
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,cw.cat.name));
You can use like this:
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'ERROR MESSAGE HERE'));
Thanks,
Vf Page:
<apex:page standardController="Account" extensions="errorMessgaes">
<apex:form >
<apex:pageblock >
<apex:pageMessages id="shwmsg"></apex:pageMessages>
<apex:panelgrid columns="2">
Account Name <apex:inputtext value="{!accountname}"/>
Account Number <apex:inputtext value="{!accountnumber}"/>
<apex:commandButton value="Update" action="{!updateAccounts}" style="width:70px" reRender="shwmsg"/>
</apex:panelgrid>
</apex:pageblock>
</apex:form>
</apex:page>
Controller:
public with sharing class errorMessgaes {
public string accountName{get; set;}
public string accountNumber{get; set;}
public errorMessgaesCLs(ApexPages.StandardController controller) {
}
public void updateAccounts()
{
if(accountName==''||accountName==null)
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please Enter Account Name'));
if(accountNumber=='' ||accountNumber==null)
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,'Please Enter Account Number'));
}
}
OutPut:
Thanks,
Rockzz
If this solves your problem, kindly mark it as the best answer.
Thanks,
Rockzz