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
samrat.1985@lntinfotechsamrat.1985@lntinfotech 

Can i auto refresh a pageBlock after specific time interval

Hi

 

Does any one have any idea about this.

I want to refresh/ reload my pageblock after regular interval. To get the new data/record form the WSDL.

Pleae revert back in case you can help or you need clarifications in this

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You can refresh elements on a visualforce page using an actionpoller component and specifying the element id in the rerender attribute.

 

The following is a straight lift from the VisualForce Developer's Guide:

 

 

<apex:page controller="exampleCon">
  <apex:form>
    <apex:outputText value="Watch this counter: {!count}" id="counter"/>
    <apex:actionPoller action="{!incrementCounter}" rerender="counter" interval="15"/>
  </apex:form>
</apex:page>

/*** Controller: ***/
public class exampleCon 
{
  Integer count = 0;
  public PageReference incrementCounter() 
  {
    count++;
    return null;
  }

  public Integer getCount() 
  {
    return count;
  }
}

 

 

All Answers

bob_buzzardbob_buzzard

You can refresh elements on a visualforce page using an actionpoller component and specifying the element id in the rerender attribute.

 

The following is a straight lift from the VisualForce Developer's Guide:

 

 

<apex:page controller="exampleCon">
  <apex:form>
    <apex:outputText value="Watch this counter: {!count}" id="counter"/>
    <apex:actionPoller action="{!incrementCounter}" rerender="counter" interval="15"/>
  </apex:form>
</apex:page>

/*** Controller: ***/
public class exampleCon 
{
  Integer count = 0;
  public PageReference incrementCounter() 
  {
    count++;
    return null;
  }

  public Integer getCount() 
  {
    return count;
  }
}

 

 

This was selected as the best answer
SSRS2SSRS2

 Use HTML META tag to refresh the page in specified time interval. Follow page refresh every 5 second.

 

<apex:page>
    <html>
        <head>
            <META http-equiv="refresh" content="5"/>
        </head>
    </html>
    From Apex tags:<br/>
    <apex:outputText value="The formatted time right now is: {0,date,yyyy/MM/dd G 'at' HH:mm:ss z}">
        <apex:param value="{!NOW()}" />
    </apex:outputText>
</apex:page>

-Suresh

 

 

 

samrat.1985@lntinfotechsamrat.1985@lntinfotech

Thanks bob and SSRS.

It really helped.

Bob this is exactly that i was looking for.

I tried it but missed the vital part of using the Pagereference class 

clarkbkclarkbk

For the purposes of better understanding this component, can anyone briefly explain why it's necessary for the controller method that's called by the actionpoller to have a return type of PageReference and a return value of 'null'?

 

Thanks!


B

bob_buzzardbob_buzzard

For a controller method to be called by an actionpoller (or a commandlink, commandbutton, actionfunction) it needs to be an action method.  An action method has a signature of public, with no parameters and a return type of PageReference or void.  If the method has a return type of PageReference but returns null, that will simply refresh the current page with the updated viewstate.