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
ShakespeareShakespeare 

Could Not Display Onscreen Success Message Though Apex Messages

Hi,

 

I have a simple multi line editor and I have to show a success message to the use when ajax call makes the insert/update. I have used <apex:pageMessages/> and message class in controller. Unfortunatley message is not displayed. Here is my code. Can somebody would help me please.

 

Regards,
Shakespeare

<apex:page controller="PixelReqFormController" showHeader="false" id="pixelReqPage"> <apex:pageMessages/> <script> function checkIsDelete() { if (confirm()) { saveRecord (); return true; } else { return false; } saveRecord (); } </script> <apex:form id="pixelReqForm"> <apex:actionFunction action="{!save}" name="saveRecord" reRender="pixelReqTable" /> <apex:pageMessages rendered="true" id="msg2"/> <apex:pageBlock title="Pixel Request Form" id="pixelReqPageBlock"><br></br> <apex:pageBlockButtons > <apex:commandButton value="Save" id="btnSave" rerender="pixelReqTable" status="outStatus" onclick="checkIsDelete()"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!PixelReq}" var="aPixelReq" id="pixelReqTable"> <apex:column headerValue="Delete" id="isDeleteColumn"> <apex:inputCheckbox value="{!aPixelReq.isDeleted__c}" id="isDelete"/> </apex:column> <apex:column headerValue="Agency"> <apex:inputField value="{!aPixelReq.Agency__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page> -------------------------------------- public class PixelReqFormController { public PageReference save() { for (integer i = 0; i < pixelReqList.size(); i++) { if (pixelReqList[i].ContracID__c == '' || pixelReqList[i].ContracID__c == null) { pixelReqList[i].ContracID__c = ApexPages.currentPage().getParameters().get('contractID'); } } upsert pixelReqList; ApexPages.Message myMsg = new ApexPages.message(ApexPages.Severity.INFO, 'Pixel Request Saved Successfully'); ApexPages.addMessage(myMsg); reset (); return null; } public PageReference reset() { pixelReqList = [SELECT isDeleted__c, Agency__c FROM PixelReqForm__c where ContracID__c = :ApexPages.currentPage().getParameters().get('contractID') AND isDeleted__c = false return null; } }

 

Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess

try this

 

 

<apex:actionFunction action="{!save}" name="saveRecord" reRender="pixelReqTable,msg2" />

 

 

so that the page can redraw that message area also

 

All Answers

Ron HessRon Hess

try this

 

 

<apex:actionFunction action="{!save}" name="saveRecord" reRender="pixelReqTable,msg2" />

 

 

so that the page can redraw that message area also

 

This was selected as the best answer
ShakespeareShakespeare

Great, Great, I thank you Hess, my issue has been resolved on you advice.

 

Thanks,

Shakespeare