Web Generate Auto-Refresh Pages with Designer

By Hervé Deschamps, Oracle Corporation.

This article presents a simple solution for producing web pages that refresh themselves automatically every 30 seconds. You can set any other time interval of course. This is a 100% generation solution.

Step 1: A bit of JavaScript

In the Design Editor, select your module and expand it in the Navigator. Double Click on the module component where you wish to add this functionality. A dialog pops up on the screen. The dialog title is "Edit Module Component <module component name>". If you do not get this dialog but see the property palette instead, select menu option: Options -> Use Property Dialogs and double-click on the module component again. Figure 1 illustrates what you ought to see in Designer in order to be able to proceed with the instructions that follow.
Figure 1
Where to place the JavaScript that performs the auto-refresh.
In the User Text tab, select "Default Area" and enter the code in Listing A.
Listing A

function refreshPeriodic() {
   // Reload the page every 30 seconds
   timerID = setTimeout("refreshPeriodic()",30000);
timerID = setTimeout("refreshPeriodic()",30000);

JavaScript code that performs the Auto Refresh.

Two side notes:

The time-out delay is expressed in milliseconds. Be careful not to set it too short. We have only tried this with NT, Netscape 4 and Web Server 3.01. In that environment, setting the interval too short results in users loosing control as the browser is constantly trying to reload the page. Also the server's memory usage spirals up and grinds the machine to a halt.

Step 2: Generate away!

Yes, that's all you need to do.

We have only tested this with Netscape. The browser does a very good job of refreshing the content of the page. If the users navigate to another page and come back to this one with browser's back arrow, the page still reloads periodically. In fact it even reloads if the browser is left in the background while the users moves to another window.

Special thanks to Feras Saghir who threw that challenge at me.

Hervé Deschamps is a Senior Principal Consultant with Oracle Corporation. He has had over five years of experience with Oracle Development Environments (Designer, Developer and previous versions). He has an extensive experience of all phases of the development life cycle with a focus in the areas of business analysis, data modeling and database design. He is also known in the technical community for his article publications centered around best custom development practices and for his user group presentations. You can reach him by e-mail at hdescham@us.oracle.com. He also maintains a web site full of articles, scripts, tips and techniques at http://www.iherve.com.