Auto Refresh

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
jimr
New User
Posts: 13
Joined: Sun Feb 05, 2012 5:44 pm
First Name: Jim
Last Name: Rohde
Company Name: TMW Systems
Phone: 440-721-2931
Address 1: 6350 Quadrangle Dr
Address 2: Suite 300
City: Chapel Hill
State / Province: North Carolina
Zip / Postal Code: 27517
Country: United States
Contact:

Auto Refresh

Post by jimr »

I have a program that in green-screen mode auto-refreshes using a *DTAQ.

I've "removed" all of the *DTAQ code in the program but would still like the screen to auto-refresh - at least on a predetermined period of time (like 'n' minutes). is there a way to do this using javascript on a PUI form?

Thanks,
Jim
dieter
Experienced User
Posts: 122
Joined: Tue May 22, 2012 6:45 am
First Name: Dieter
Last Name: Schröder
Company Name: Ecclesia Holding GmbH
State / Province: Outside Canada/USA
Country: Germany
Contact:

Re: Auto Refresh

Post by dieter »

Jim,

a colleague did that with the following javascript snippet:
setTimeout("document.getElementById('TextBox1').value='5 seconds!' ",5000);

The script ist used in the Onload Event of the screen. It uses a field named "TextBox1" which shows the value "5 seconds!" every 5 seconds.


For refreshing the screen under control of an RPG program we use the following method: On the screen we have a textbox named "txtRefresh" with an assigned RPG-Field "REFRESH". In the Onload-Event of the screen we have the following javascript code:
if (getElementValue("txtRefresh")=="AUTO") { changeElementValue("txtRefresh", ' ');pui.click();};

So in our RPG-program we can assign the value "AUTO" to the variable REFRESH and than do an EXFMT. Then the javascript starts on the Onload event. It sets the screen element txtRefresh to blank (so the value "AUTO", which was set by the RPG program, is no longer in the field). Note that the element "txtRefresh" is dedicated to the RPG-variable "REFRESH"!). Than the script makes a "pui.click", so the control goes back from the browser to the RPG-Programm. With this method you can change variables on the screen via your RPG program and refresh the screen.

I hope you can understand my English. (I am from Germany).

Best regards,
Dieter
jimr
New User
Posts: 13
Joined: Sun Feb 05, 2012 5:44 pm
First Name: Jim
Last Name: Rohde
Company Name: TMW Systems
Phone: 440-721-2931
Address 1: 6350 Quadrangle Dr
Address 2: Suite 300
City: Chapel Hill
State / Province: North Carolina
Zip / Postal Code: 27517
Country: United States
Contact:

Re: Auto Refresh

Post by jimr »

Thanks dieter,

I see what you are doing here - I want sort of a combination of the two. The subfile grid also needs to be usable during the timeout period. So far not working the way i want it too.

-jim
Antonio
Profound User
Posts: 82
Joined: Fri Jun 29, 2012 2:33 pm
First Name: Antonio
Last Name: Ruballos
Company Name: Profound Logic
Contact:

Re: Auto Refresh

Post by Antonio »

Hello Jim,

I believe you could use the javascript function setTimeOut(expression, timeout) to accomplish what you need. What setTimeout() does is run expression after timeout milliseconds have gone past. So if you put the following line inside of the onload event of that screen:

setTimeout(function(){ pui.click()}, 3000);

It would refresh every 3 seconds. Let me know if you need further assistance.

Thanks!
jimr
New User
Posts: 13
Joined: Sun Feb 05, 2012 5:44 pm
First Name: Jim
Last Name: Rohde
Company Name: TMW Systems
Phone: 440-721-2931
Address 1: 6350 Quadrangle Dr
Address 2: Suite 300
City: Chapel Hill
State / Province: North Carolina
Zip / Postal Code: 27517
Country: United States
Contact:

Re: Auto Refresh

Post by jimr »

Antonio,

That works pretty well. Is there a way I can control whether or not the java script runs from my RPG (turn it on and off) and modify the milliseconds with a variable? I assume there's a reason why none of the event properties can be bound to a field...

Thanks,
Jim
jimr
New User
Posts: 13
Joined: Sun Feb 05, 2012 5:44 pm
First Name: Jim
Last Name: Rohde
Company Name: TMW Systems
Phone: 440-721-2931
Address 1: 6350 Quadrangle Dr
Address 2: Suite 300
City: Chapel Hill
State / Province: North Carolina
Zip / Postal Code: 27517
Country: United States
Contact:

Re: Auto Refresh

Post by jimr »

Antonio,

That works pretty well. Is there a way I can control whether or not the java script runs from my RPG (turn it on and off) and modify the milliseconds with a variable? I assume there's a reason why none of the event properties can be bound to a field...

Thanks,
Jim
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Auto Refresh

Post by Scott Klement »

One way would be to include a hidden field on the screen containing the number of seconds (or milliseconds). Your JavaScript routine could check the value of the hidden field to get the timeout value -- or if a special value (maybe -1?) is found, it could choose not to do the setTimeout.
matts
New User
Posts: 2
Joined: Wed Jul 15, 2015 5:34 pm
First Name: Matt
Last Name: Seeberger
Company Name: Dupre Logistics
Contact:

Re: Auto Refresh

Post by matts »

Is there a way that I can allow the user to select the refresh interval? The onload screen refresh works perfectly but I would like to let the user select the amount of seconds between refreshes. If this is possible I could let them type in a value or select it from a dropdown box.

Thanks.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Auto Refresh

Post by Scott Klement »

Yes, you can have the user select it if you wish. You would probably want to code this on an 'onchange' event so that when the user selects a different time interval, it cancels the existing timer and sets up a new one.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 6 guests