+ Start a Discussion
Denys PeresDenys Peres 

Rerender not fetching new data

Hi. I am trying to use actionPoller to fetch data updated through a @future call (just the field being updated asyncronously, Future_Date__c), but it seems that the data in the StandardController is stuck in the original value, even though the fetch date is changed. Do you know how to trigger the standard controller to get the new data and refresh that part of the view?
<apex:page standardController="Case" cache="false" >
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:outputPanel id="blockToRerender" >
                <apex:form >
                    <apex:outputLabel value="Future Date: " />
                    <apex:actionStatus id="counterStatus" startText="Fetching…" stopText="Done!" rendered="{!ISBLANK(Case.Future_Date__c)}" />
                    <apex:outputText value="{!Case.Future_Date__c}" />
                    <br/><br/>
                    <apex:outputLabel value="Fetch Date: " />
                    <apex:outputText value="{!Now()}" />
                    <apex:actionPoller oncomplete="refreshJS();" interval="5" status="counterStatus" enabled="{!ISBLANK(Case.Future_Date__c)}" />
                    <apex:actionFunction name="refreshJS" reRender="blockToRerender" /> 
                </apex:form>
            </apex:outputPanel>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

 
Best Answer chosen by Denys Peres
sandeep@Salesforcesandeep@Salesforce
Hi Denys,

I think your expected data (Future_date__c) would only be rendered (refreshed) on page if it is bind with a variable( public getter ) in controller. Right now your field is a part of standard controller and there is not method ( with logic) implemented behind the screen which can be executed in given time interval and provide you updated result on screen.

If this helped  you to resolve your problem then please mark this as best answer so that it can be useful for others. . 

Thanks
Sandeep Singhal
http://www.codespokes.com/

All Answers

sandeep@Salesforcesandeep@Salesforce
Hi Denys,

I think your expected data (Future_date__c) would only be rendered (refreshed) on page if it is bind with a variable( public getter ) in controller. Right now your field is a part of standard controller and there is not method ( with logic) implemented behind the screen which can be executed in given time interval and provide you updated result on screen.

If this helped  you to resolve your problem then please mark this as best answer so that it can be useful for others. . 

Thanks
Sandeep Singhal
http://www.codespokes.com/
This was selected as the best answer
Denys PeresDenys Peres
@sandeep

I figured it had something to do with the standard controller behavior, so you could either write a custom controller or make an extension that always fetches the data, no matter if the sObj is null or not:
 
public with sharing class EX_RefreshConsole {      
  public case caseEx {
      get{
       caseEx = [Select Id,Future_Date__c from case where Id =: ApexPages.currentPage().getParameters().get('id')];
       return caseEx;
      }
      set;
    }
    public EX_RefreshConsole(ApexPages.StandardController controller) {}
    public PageReference getNewData(){
      return null;
    }
}
 
And then... 
 
<apex:page standardController="Case" cache="false" extensions="EX_RefreshConsole" >
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:outputPanel id="blockToRerender" >
                <apex:form >
                 <apex:outputLabel value="Future Date: " />
                 <apex:actionStatus id="counterStatus" startText="Fetching…" stopText="{!caseEx.Future_Date__c}" />
                 <apex:actionPoller oncomplete="refreshJS();" interval="5" status="counterStatus" enabled="{!ISBLANK(caseEx.Future_Date__c)}" />
                 <apex:actionFunction action="{!getNewData}" name="refreshJS" reRender="blockToRerender" /> 
                </apex:form>
            </apex:outputPanel>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

Unpolished, but it works. Thanks!