Oracle APEX report refresh the easy way

I’ve seen numerous solutions for partial page refreshes. All using javascript, timers etc.

I just want a report to refresh itself after 5 seconds.

I add this to the region-footer:

<script type="text/javascript">
<!--
setInterval( "$a_report('##REGION_ID#'.substring(1), 1, 7, 7);", 5000);
//-->
</script>

On request of Patrick Wolf (in the remarks below) this also works:

<script type="text/javascript">
<!--
  setInterval("jQuery('##REGION_ID#').trigger('apexrefresh');", 5000);
//-->
</script>

No extra javascript functions, no dificult parameters, works for multiple regions..

Essentially it will do a region refresh using the $a_report apex-javascript function only once (after 5 seconds)..

But when the region gets refreshed…. this region-footer gets executed again…. hence: a refresh every 5 seconds.

$a_report takes these parameters:

  1. the region_id that needs to be refreshed. (apex puts an ‘R’ in front of it. the substring(1) removes the ‘R’ again)
  2. the 1st record to show
  3. the last record to show
  4. the number of records to show
  5. sorting

I hope this helps.

9 comments for “Oracle APEX report refresh the easy way

  1. koloo2000
    27 August 2012 at 02:08

    Hi,
    but how do you refresh only one report region on a page using dynamic action tied to a button? thank you.

  2. Sofia_pro@yahoo.com
    1 June 2012 at 17:31

    Thanks Richard,
    Worked great for me. I was doing whole page refresh, but region refresh is match better. You don’t have a blinking page!
    But instead of region number I placed div tag in header of the region and used it as a selector.
    setInterval(“jQuery(‘#my_dev’).trigger(‘apexrefresh’);”, 5000);

    Best,
    Sofia

  3. Wilson
    8 February 2012 at 05:21

    Please, how to implement a timer(hh:mi:ss) in oracle apex. I review the documentation but don“t understand, can you say me peer to peer how to do.

    Thanks,
    Wilson

    • Richard Martens
      8 February 2012 at 17:25

      @Wilson,
      What exectly do you want to accomplish.

      I’m happy to write an article.

      regards,
      Richard

  4. Ola
    7 February 2012 at 15:57

    Hi !

    I tried to use the timer plugin but it refresh report with page items
    but the with code snippet above it works great.

    Regards Ola

  5. Richard Martens
    20 October 2011 at 15:02

    Frank,

    Hmm.. I don’t see where I’m using a plugin. Maybe you can try Patrick’s suggestion below. Otherwise try to get infromation from the plugin developer.

    Regards,
    Richard

  6. Frank Reijenga
    20 October 2011 at 14:32

    I tried to use the timer plugin.
    It works fine for periodically refresh reports (e.g. select to_char(sysdate,’HH24:MI:SS’) from dual), but I can’t get it working to refresh page items (or regions with page items).
    Any suggestions to get this item refresh working with the timer plugin are welcome.
    Thanks, Frank

  7. 27 April 2011 at 18:51

    Hi Richard,

    I would suggest to not use undocumented and unsupported APEX Javascript APIs. It’s very likely that we will change them in the future.

    If you are on APEX 4.0 you can use

    jQuery('#STATIC_ID_OF_REGION').trigger('apexrefresh');

    to refresh a region or you just use the “Refresh” dynamic action in combination with the Timer dynamic action plug-in from

    Regards
    Patrick

Leave a Reply