Displaying a Widget in a new Window in GWT

戏子无情 提交于 2019-12-25 04:05:27

问题


I have a requirement wherein I need to display a drag n drop cell table in a new window. I have checked for answers and I have googled about this, but I did not get appropriate answers. I am able to open a new window on click of a button. Following is the code which I am using:

@UiHandler(value = { "buttonReleaseView" })
    void onReleaseViewClick(ClickEvent clickEvent) {
        String winUrl = GWT.getModuleBaseURL() + "releaseView/";
        String winName = "Release View";

        openNewWindow (winName, winUrl);  /* spawn a new window - not popup */
    }

    /**
    * Opens a new windows with a specified URL..
    * 
    * @param name String with the name of the window.
    * @param url String with your URL.
    */
    public static void openNewWindow(String name, String url) {
        com.google.gwt.user.client.Window.open(url, name.replace(" ", "_"),
               "menubar=no," + 
               "location=false," + 
               "resizable=yes," + 
               "scrollbars=yes," + 
               "status=no," + 
               "dependent=true");
    }

Now, how should I display cell Table in this new window?

Please help me out.

Thanks in advance

Richa


回答1:


A GWT module lives inside a browser page, so if you want to open a new browser page and display GWT components inside it, you basically need to load a new GWT module in it's own host page. I would probably use a popup window in this case, since it would be way simpler.

But if you really need to do it, you could either create a separate host page and GWT module to display the table, or you could reuse the same host page and GWT module and pass some URL parameter or history token to indicate which view to display. Keep in mind that even in this last case, you would still have two instances of the GWT module running in the browser.

There are also more or less hackish ways to write directly to the new browser window by calling document.write on the handle returned by Window.open(), but I would only do that for simple things that don't require too much user interaction (e.g. I've used this approach for a Print Preview feature).



来源:https://stackoverflow.com/questions/11325160/displaying-a-widget-in-a-new-window-in-gwt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!