Close browser window automatically

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
Tonis
New User
Posts: 9
Joined: Thu Dec 18, 2014 4:03 am
First Name: Toni
Last Name: Schaake
Company Name: Mediscor
City: Centurion
Country: South Africa
Contact:

Close browser window automatically

Post by Tonis »

Hi,

I have an application that requires me to close the browser window when a button is pressed.

Currently the process flow is as follows:

1. Screen displays.
2. User enters data.
3. User press save button.
4. Control returns to RPG program, validates the captured data.
5. If Validation = OK, save captured data and end program. If Validation = "error", activate error message on same form (message line), and re-display the same form.

I am currently using the button's response property. I've tried to use a hidden button and set it's response property and then do a pui.click("hidden button") on the original button, as described on another post on the forum, but no success.

What is needed:
Steps 1 to 4 as above.

5. If Validation = OK, save captured data and end program, and close the browser window.

If Validation = "error", activate error message on same form (message line), and re-display the same form.

I have some JS that close the browser window, but control is never returned to program. I am aware that a single button cannot have both a response property and an onclick event.

I have set both pui.skipConfirm = true and pui.confirmOnClose = false on the record format.

Any ideas as to how I can implement this?

Kind Regards,

Toni.
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: Close browser window automatically

Post by Scott Klement »

Toni,

Web browsers restrict who/when/how a window can be closed. The rule is usually that only the same web site that opened a window can close it -- but this may vary depending on the browser and the security settings that are used. This is something built into the browser itself, Profound does not have control over it. remember, a Rich Display is "just a web page", and a browser doesn't know it should be treated differently than any other web page you see out on the Internet, etc.

So with that in mind:

1) You can try to close a window, but you should expect cases where it might fail. In those cases, you should be ready to do something like print "session ended, please close the browser window." (This is what Profound UI does, for example, when it fails to close a window.)

2) Remember that when you close the window, you also end any code that's running in the Window. This includes the Rich Display runtime or Genie runtime code. So it will stop communications to IBM i, and it ma not have the chance to close the server-side program. You should, therefore, consider coding something where the program ends itself, and then the front-end detects this and closes its window. Otherwise, if you just "kill" the window, there won't be code running to shut down the server-side program.

I'm interested in why/how your application would require the window to be closed. This is a very unusual situation. Why would anyone have that requirement?

Thanks
Tonis
New User
Posts: 9
Joined: Thu Dec 18, 2014 4:03 am
First Name: Toni
Last Name: Schaake
Company Name: Mediscor
City: Centurion
Country: South Africa
Contact:

Re: Close browser window automatically

Post by Tonis »

Hi Scott,

Thanks for your reply.

We're trying to consolidate our call logging. (Capturing call details etc. for every call the help desk consultants receive.) The profound session is initiated from the PABX system, so once a consultant receives a call, a new profound (browser) window is opened on the consultant's desktop, with the current call details available to the consultant. The consultant handles the call, and upon completion the consultant either transfers the call, or end the call. Both instances requires the consultant to supply the call details (Who\Why\action taken\notes etc.). I've attached a screenshot of the screen.

After a couple of calls, the consultant sits with a number of open browser windows on his desktop. Therefore the requirement to close the browser when the consultant clicks on the "Submit and Disconnect" button.

Kind Regards,

Toni.
Attachments
MCIC.JPG
MCIC.JPG (84.6 KiB) Viewed 1442 times
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: Close browser window automatically

Post by Scott Klement »

I see.

My suggestion, as I touched on in my last message, would be for the RPG program to end normally. This should take you to the "Your session has ended" screen. My thought is to have code on that session has ended screen that closes the window. This way, all of the communications should be complete and the session can end normally.

You can do that by opening the product-library/QDDSSRC,PUISCREENS member in the Visual Designer. (By default, the product is installed into the PROFOUNDUI library, so it'd be PROFOUNDUI/QDDSSRC, but the library can be changed during installation.) The record format is called EOJSCREEN. Here you should see the same screen that happens when your RPG program ends.

My idea is to have the "onload" for that screen call the pui.closeSession() API. This should close the window (if possible.) So when sessions end, the window gets closed. You could potentially make that conditional (check for a global JavaScript variable or some setting in sessionStorage, etc) and only call the pui.closeSession() API under particular circumstances... but that's the basic idea, do it when end-of-job screen is displayed so you know the program and everything has already shut down properly.
Tonis
New User
Posts: 9
Joined: Thu Dec 18, 2014 4:03 am
First Name: Toni
Last Name: Schaake
Company Name: Mediscor
City: Centurion
Country: South Africa
Contact:

Re: Close browser window automatically

Post by Tonis »

Thank you Scott.

I'll give that a bash and let you know.

Best Regards,

Toni.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests