+ Start a Discussion
Sergio Mac IntoshSergio Mac Intosh 

My apexmessages aren't showed

My apexmessages aren't showed! Can someone help me out? 

Visualforce:
<apex:pageMessages></apex:pageMessages>
    
    <apex:form>
    <apex:actionFunction name="showSuccess" action="{!showSuccess}" rerender="messages">
        <apex:param name="message" assignTo="{!message}" value="" />
        <apex:param name="messageType" assignTo="{!messageType}" value="" />
    </apex:actionFunction>
    </apex:form>
Javascript:
showSuccess('Logo uploaded succesfull', 'SUCCESS');
Apex:
public string message{get; set;}
    public string messageType{get; set;}


 public void showSuccess(){
        if(messageType == 'SUCCESS'){
system.debug('TestMessage' + message);
            ApexPages.Message alertMsg = new ApexPages.Message(ApexPages.Severity.CONFIRM,'TESTSUCCESS');
			ApexPages.addMessage(alertMsg); 
        	///ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM, message));
        }else if(messageType == 'WARNING'){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, message));
        }else if(messageType == 'ERROR'){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, message));
        }

  	}
My system.debug is visible in the debug logs but the apex message doesn't appear.
Im using it in chatter (VF Chatter Action)

Thanks,

Sergio

 
Best Answer chosen by Sergio Mac Intosh
James LoghryJames Loghry
Try specifying id="messages" in your apex:pageMessages tag.  That is afterall, what the rerender attribute is pointing to  (the id of one of the tags).

If that doesn't work, then post your entire VF.  Perhaps somethign else is going on in the markup we can't see.

All Answers

James LoghryJames Loghry
Try specifying id="messages" in your apex:pageMessages tag.  That is afterall, what the rerender attribute is pointing to  (the id of one of the tags).

If that doesn't work, then post your entire VF.  Perhaps somethign else is going on in the markup we can't see.
This was selected as the best answer
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for Apex Message
1) http://www.sfdcpoint.com/salesforce/show-error-message-visualforce-page/
2) https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_System_ApexPages_addMessage.htm

I hope you added the <Apex:pageMessages tab in your VF page
<apex:pageMessages id="showmsg"></apex:pageMessages>
Please add id in pageMessage tag and add rerender="showmsg" tag to refersh.

Like below 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}"/>
           Account Number: <apex:inputText value="{!acc.AccountNumber}"/>
           Account Phone: <apex:inputText value="{!acc.phone}"/>
           Account Site: <apex:inputText value="{!acc.site}"/>
           Account Industry: <apex:inputText value="{!acc.industry}"/>
           <apex:commandButton value="Update" action="{!save}" style="width:90px" rerender="showmsg"/>
         </apex:panelGrid>
    </apex:pageblock>
 </apex:form>
</apex:page>

Apex Class
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'));
 
      if(acc.AccountNumber == '' || acc.AccountNumber == null)
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please enter Account number'));
 
      if(acc.phone == '' || acc.phone == null)
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter Account phone'));
 
      if(acc.site == '' || acc.site == null)
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Please enter Account site'));
 
      if(acc.industry == '' || acc.industry == null)
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Please enter Account industry'));
 
    }
}


Let us know if this will help you