I have a few validation rules which display errors on fields. This is working fine for Standard Pages. But when these validations fail on a VisualForce page, the error messages show on the top of the page in "apex:messages". Is there a way to show these messages on the fields, without re-creating the validation checks in Apex or VisualForce page.
UPDATE: For example:
APEX:
public PageReference save() {
try
{
//controller.save();
update application;
}
catch(DmlException e)
{
application.addError(e);
//ApexPages.addMessages(e);
return null;
}
catch (Exception e)
{
//application.addError(e);
ApexPages.addMessages(e);
return null;
}
return null;
}
VISUALFORCE
<apex:outputpanel id="Messages">
<strong><apex:messages style="color:red;"/></strong>
</apex:outputpanel>
<apex:inputField value="{!application.Field_Having_Validation_Rule__c}" />
<apex:commandButton action="{!save}" value="Save" reRender="Messages" status="saveStatus" />
. When I removed the reRender attribute, its showing the error on the field. The problem now is that its showing the error on the field as well as top of the page.