Timer event in a PUI program.

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
nascar88
Profound User
Posts: 42
Joined: Wed Aug 04, 2010 5:12 pm
First Name: Bob
Last Name: Steach
Company Name: APHA
Contact:

Timer event in a PUI program.

Post by nascar88 »

I would like to return to my rpgle pgm every xx minutes to see if a control record has been changed and if so, reload a subfile based on the changed record.

I am not a java programmer, but after searching the web I found the following code but can't figure out if / how to make it work in the onLoad event.

If anyone is doing this --- I would appreciate your help.

----------------------------------------------------------------
import java.util.Timer;
import java.util.TimerTask;

public class Main {
public static void main(String[] argv) throws Exception {
int delay = 5000; // delay for 5 sec.
int period = 1000; // repeat every sec.
Timer timer = new Timer();

timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
System.out.println("doing");
}
}, delay, period);
}
}
----------------------------------------------------------------
User avatar
David
Profound Logic Staff Member
Posts: 690
Joined: Fri Jan 04, 2008 12:11 pm
First Name: David
Last Name: Russo
Company Name: Profound Logic Software
Contact:

Re: Timer event in a PUI program.

Post by David »

What you want is JavaScript, rather than Java. Although the name is similar, they are entirely different programming languages.

You cannot call Java code directly using browser events -- these are handled by JavaScript.

Basically, you could accomplish what you want with:

1. Using JavaScript's setTimeout() method to run a JavaScript function after X number of seconds.

2. The JavaScript function that runs on the timer can call Profound UI's "pui.click()" JavaScript API to submit the page to the server. This function accepts an optional button id, so you can simulate a click on a (probably hidden) button with response indicator bound. This way your RPG code would know that the screen is submitting for this vs. another reason.

But, it might not be quite so simple. To make this user friendly, you'd probably want to reset the timer if the user takes some action on the screen so that it's not "leaving without them".

You could do that by storing the return value from setTimeout() and then clearing/resetting it if the user has moved the mouse or keyboard.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest