I have a pretty batch that is trigger from a VF page. Then I check the batch status using an ActionPoller until it is completed and finally I rerender the batch results.

Everything is working fine but the pageMessages rerender. I can't figure out why.

I could check that the msgPanel is rerendering ok using the NOW. But the ApexPage.Messages is empty.

My VF looks like this:

<apex:outputPanel id="msgPanel">
      <apex:pageMessages id="msg"/>

 <apex:actionPoller interval="5" action="{!checkBatchStatus}" enabled="{!batchStatus}" onsubmit="console.log('checking..');" oncomplete="{!batchComplete}&&refreshJS();" />

<apex:actionFunction action="{!refreshGenerate}" name="refreshJS" reRender="msgPanel,resultsPanel" /> 

In the controller I have this:

public PageReference checkBatchStatus(){

            AsyncApexJob job    =   [select........1];
        if(job.Status == 'Completed'){

            ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.CONFIRM ,
             currentBatch+' Completed. '));
            //some internal checks
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR ,errorDescription);

            batchComplete = true;
            batchStatus = false;

         batchStatus = true;
  return null;
   public void refreshGenerate(){ 
      // empty method, it is just used by javascript to trigger some rerenders.

Is this a rerender bug of salesforce ?

Please help

  • What does the refreshGenerate apex function do? Can't you just put the rerender attribute on the actionPoller instead of the actionFunction?
    – rael_kid
    Sep 13 '14 at 20:27
  • refreshGenerate do nothing, Im using it as a javascript helper to handle the rerender from javascript, I can't use the rerender on the actionPoller because it is called each time the poller is executed and I only need to rerender when the poller check that the batch has completed.
    – jm-cloud
    Sep 13 '14 at 22:48
  • In this case I would just put the rerender on the actionPoller. The AJAX call will be done anyway, I don't expect the rerender to affect the performance. Have you tried it?
    – rael_kid
    Sep 14 '14 at 8:25
  • 2
    And what happens if you only rerender the msgPanel from the actionPoller?
    – rael_kid
    Sep 14 '14 at 8:39
  • 2
    Amazing, it worked. It seams like actionPoller onComplete event is doing something weird in the stateview, cleaning the ApexPage.message. I think that the lack of performance is not an issue. Post your answer. I'll be glad to accept it.
    – jm-cloud
    Sep 14 '14 at 9:26

It seems that the pageMessages behave a bit like a transient variable. Since you rerender the pageMessages element in another request (the actionFunction, rather than the actionPoller), the values are resetted. I haven't confirmed this yet.

If you move the rerender of the pageMessages element as a part of the actionPoller it will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.