function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rafael.Martins.SantosRafael.Martins.Santos 

How display an error message on the visualforce page?

Hi All,

I want know how display an error message on the visualforce page?

Thanks
Rafael
Raj VakatiRaj Vakati
Please refer this link 

http://www.sfdcpoint.com/salesforce/show-error-message-visualforce-page/
Ajay K DubediAjay K Dubedi
Hi Rafael,

VisualForce Page Code.
<apex:page standardController="Account" extensions="ErrorMessageInVfController">
 <apex:form >
   <apex:pageblock >
  	<apex:pageMessages id="showmsg"></apex:pageMessages>
     	<apex:panelGrid columns="2">
       	Account Name: <apex:inputText value="{!acc.name}"/>
       	<apex:commandButton value="Update" action="{!save}" style="width:90px" rerender="showmsg"/>
     	</apex:panelGrid>
	</apex:pageblock>
 </apex:form>
</apex:page>

Apex Code.
public with sharing class ErrorMessageInVfController
{
	public Account acc{get;set;}
	public ErrorMessageInVfController(ApexPages.StandardController controller)
	{
    	acc = new Account();
	}
 
	public void save()
	{
  		if(acc.name == '' || acc.name == null)
{
  			ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Please enter Account name'));
		}
	}
}

Here is screen shot of the desired output.
User-added image
Regards,
Ajay.
If this answers your query please mark this question as a solved so that it can be filtered out from  unsolved questions.
Rafael.Martins.SantosRafael.Martins.Santos
Hi Ajay,

Sorry, this don't work.
follow my page:

User-added image

I'm using this apex page:
<apex:page showHeader="false" sidebar="false" standardStylesheets="false"
applyHtmlTag="false" applyBodyTag="false" docType="html-5.0" controller="Account_Mancha">

So I need to show a message in this page.
is it possible?

Thanks