window.showModelDialog replacement

3,458 views
Skip to first unread message

David

unread,
May 24, 2016, 5:02:52 AM5/24/16
to GWT Users
I am using GWT to improve an existing web site written in ASP. This site has a lot of window.showModalDialog. It needs to run in Android phones too. The window.showModalDialog has been disabled by Chrome it is giving me error as "undefined is not a function". I can use window.open to replace it. But I can not get a return value from window.open. 
Can anyone please tell me what is the alternative for the window.showModelDialog or how to get a return value from window.open?

Thanks,

David

Chad Vincent

unread,
May 24, 2016, 9:45:58 AM5/24/16
to GWT Users
I normally use a custom DialogBox ( http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/ui/DialogBox.html ), since it is within-document, I can do whatever I need to in it (validation, Widgets, prompt for input using a custom widget, etc.), and it doesn't block other tabs.

David

unread,
May 24, 2016, 6:58:13 PM5/24/16
to GWT Users
Old window.showModalDialog returns a value into opener (parent window). Because this application is old and uses a lot of window.showModalDialog which belongs to IE built-in javascript function.. I need to write window.showModalDialog replacement for Chrome and some mobile devices. I do appreciate your any suggestions.

Thomas Broyer

unread,
May 25, 2016, 3:12:04 AM5/25/16
to GWT Users
You won't find any equivalent. The platform has moved over to an "all async" model so you'll have to rewrite this code to work asynchronously (including handling other events while waiting for the "return value" to be passed into a callback/event/whatever.

This isn't really a GWT question though, it's more about the web platform.

David

unread,
May 25, 2016, 9:56:45 AM5/25/16
to GWT Users
How do I simulate IE window.showModalDialog to present a user with a widget (dialog) that blocks main thread till the user closes that widget, method return?

Paul Stockley

unread,
May 25, 2016, 9:57:43 AM5/25/16
to GWT Users
What we did in our project to migrate these kind of modal windows on IE was as follows:-

1) Create a GWT modal dialog with an iframe in it and point this to the url for the window.
2) Add some code to the existing page to talk to the parent GWT window to close the dialog when the user clicks the submit or close button

There are quite a few more details to get it working smoothly but it works well. We also moved the submit/action/cancel buttons out of the legacy page and used GWT to render them. We then call into methods in the iframe when the user clicks on the GWT buttons. 

If you need more details I can give you a few tips. Unfortunately I can't share code because we don't use standard GWT widgets.

JonL

unread,
May 25, 2016, 1:25:11 PM5/25/16
to GWT Users
There is a new html5 dialog element that is being implemented in various browsers and a pollyfill that will give you what you need, cross posted from my reply on the GWT google+ community:

Message has been deleted

David

unread,
Jun 2, 2016, 9:05:38 AM6/2/16
to GWT Users
Because I don't have source code for old application so I could not move the submit/action/cancel buttons out of the legacy page with using GWT to render them

I have two questions
1. Based on showModalDialog, must a child page have "window.returnValue = somevalue" before it is closed? 
2. Does https://github.com/GoogleChrome/dialog-polyfill provide the same functionality with IE showModalDialog

Thanks,

David
Reply all
Reply to author
Forward
0 new messages