DDS display files have a waitrcd parameter so that the rpg program regains control if there has been no data received from the display file within the waitrcd interval.
Can pui.onbeforetimeout be used in such a way that the rpg program can save what is on the screen input fields before the timeout takes place?
If that is possible, could you please provide some sample code or give directions on how this would be accomplished.
pui.onbeforetimeout
-
- Profound User
- Posts: 52
- Joined: Mon Sep 19, 2011 3:00 pm
- First Name: Bruce
- Last Name: Anthony
- Company Name: The State Bar of California
- Contact:
-
- 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: pui.onbeforetimeout
WAITRCD is a green-screen thing. It will not work in a web environment. In web, the browser must do something in order for data to be exchanged between the browser and the server. Only when the browser initiates it will something happen.
Imagine if any/all web servers out there could change your screen at any time (rather than just when you request it). A shopping site (say, Amazon) would pop up "special offers" whenever they felt like it. Spammers would pop up ads nonstop. It'd be crazy. It can't happen, though -- a web server cannot initiate a screen. You will only see the page of your shopping site when you ask to visit it.
Profound UI cannot change that rule. Your DDS (or RPG) cannot tell the screen to "stop waiting for input". So something like WAITRCD that comes from the server cannot work in web.
Instead, what you can do to make the screen stop waiting for input is to put some JavaScript in your display file -- JavaScript runs in the browser, so it can initiate the request for something to happen. What you would do is start a timer when the screen loads, and have that timer submit the screen after a certain amount of time has passed. If the user submits the screen, you would have to cancel the timer (so it is not submitted twice.)
For example in the screen's onload event you could code this:
setTimeout() starts a timer that will run a function after a certain number of milliseconds. In this case, the function runs pui.click() API (which submits the screen, with no parameters, pui.click() is the same as pressing ENTER) and it will run after 10000 milliseconds (which is 10 seconds).
To cancel the timer if the user submits the screen, you would set your onsubmit event to:
pui.onbeforetimeout is for when your session times out due to the user being inactive. It is not related to this. But, don't worry, when you run pui.click(), as above, it will submit the screen the same as if the user pressed enter, so all the data will be sent back to your program.
If you want to know that there was a timeout (vs. the user pressing enter) you can add a button to the screen, and set it's visibility to "hidden". That way, the user cannot click it. Change it's "id" property to something like "timeoutButton". Bind it's response property to an indicator like "TimedOut". Then, change the pui.click() to pui.click("timeoutButton") and that will cause the "TimedOut" indicator to be set to *ON in your RPG. That way you know that the screen timed out instead of the user hitting enter.
Good luck
Imagine if any/all web servers out there could change your screen at any time (rather than just when you request it). A shopping site (say, Amazon) would pop up "special offers" whenever they felt like it. Spammers would pop up ads nonstop. It'd be crazy. It can't happen, though -- a web server cannot initiate a screen. You will only see the page of your shopping site when you ask to visit it.
Profound UI cannot change that rule. Your DDS (or RPG) cannot tell the screen to "stop waiting for input". So something like WAITRCD that comes from the server cannot work in web.
Instead, what you can do to make the screen stop waiting for input is to put some JavaScript in your display file -- JavaScript runs in the browser, so it can initiate the request for something to happen. What you would do is start a timer when the screen loads, and have that timer submit the screen after a certain amount of time has passed. If the user submits the screen, you would have to cancel the timer (so it is not submitted twice.)
For example in the screen's onload event you could code this:
Code: Select all
window.savedTimer = setTimeout( function() { window.savedTimer=null; pui.click(); }, 10000 );
To cancel the timer if the user submits the screen, you would set your onsubmit event to:
Code: Select all
if (window.savedTimer != null) clearTimeout(window.savedTimer);
If you want to know that there was a timeout (vs. the user pressing enter) you can add a button to the screen, and set it's visibility to "hidden". That way, the user cannot click it. Change it's "id" property to something like "timeoutButton". Bind it's response property to an indicator like "TimedOut". Then, change the pui.click() to pui.click("timeoutButton") and that will cause the "TimedOut" indicator to be set to *ON in your RPG. That way you know that the screen timed out instead of the user hitting enter.
Good luck
Who is online
Users browsing this forum: No registered users and 0 guests