I have a visualforce page with custom controller. I have added apex:pagemessages tag below pageblock. I have a method say method1 which updates a record in obj A which inturn updates obj B via trigger. But a validation rule in obj B fails.

My code is as follows:

public void method1(){
  update rec;
 catch(System.DmlException e){ 
   ApexPages.Message msg = new apexPages.Message(Apexpages.Severity.ERROR, e.getdmlMessage(0));

But this error message is not shown in vf page. This error is seen as excpetion in the debug logs.

  • How you are calling method1() from vf page. Try changing the return type on method1() as PageReference instead of void. Hope this may work.
    – Nebula
    May 27, 2015 at 10:16
  • tried using pagereference.. but the error is still not appearing in visualforce page May 27, 2015 at 10:27
  • Can you post your VF code as well where you call method1? Are you rerendering the page message component there?
    – highfive
    May 27, 2015 at 10:32
  • Please share the vf code where you are showing the message.
    – Nebula
    May 27, 2015 at 10:32
  • <apex:page controller="some controller"> <apex: form> <apex:pageblock> <apex:pagemessages/> <apex:pageblocktable>................... </apex:pageblocktable></apex:form></apex:page> I am also using some jquery pulgins for sorting the columns May 27, 2015 at 10:51

2 Answers 2


I tried with your VF page and it is working for me. Click the reload button to see the message.

VF Page - testerrorpage

<apex:page controller="TestErrorClass">
<apex:form >
    <apex:pageblock >
        <apex:pagemessages />
        <apex:commandButton action="{!processtempcount}" value="Reload"/>


public class TestErrorClass {
  public Integer myInt { get; set; }
  public TestErrorClass (){
      myInt = 0;
  public pagereference processtempcount(){
      pagereference p = apexpages.Currentpage();
      apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'Total Number of reloads: ' + (myInt++));
      return p; 

Can you please post your VF page code, just check if you have added apexpage:messages attribute in your page

  • I have added the pagemessages attribute to the page. Will the usuge of jqueryUI interrupt the display of error messages May 27, 2015 at 12:15
  • Please try to change the position of the error msg displayed, that is if it is displayed in top of the page change it to the field or vice versa May 27, 2015 at 12:18
  • 1
    I changed the position of the pagemessages tag and it finally worked for one page. I had put the page messages tag after apex:form tag. I just moved it above form tag. and it worked now. Really wierd ! Let me try for others as well. Thanks all for your help! May 27, 2015 at 12:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .