Recently I was implementing help infrastructure for our application. I wanted to have a help window open as a real popup and not a div popup that can hold smartgwt widgets to show help info.
There was no direct support for this in gwt or smartgwt however this can be achieved with a small hack.
Open a popup window by using the following JSNI script. This opens a new window popup with your own parameters and return the document from JSNI method. This gives you handle to popup’s document element.
private static native Document createWindowPopup() /*-{
var win = window.open("", "win", "width=500,height=300,status=1,resizeable=1,scrollbars=1"); // a window object
win.document.open("text/html", "replace");
win.focus();
return win.document;
}-*/;
If you have handle to this document object you can simply add any widget to this document by
document.appendChild(myWidget.getElement());
Dont forget to close the document after writing to it.
private static native void closeDocument(Document document) /*-{
document.close();
}-*/;
No comments:
Post a Comment