Opening a new Window with a Widget in GWT

前端 未结 3 1629
时光说笑
时光说笑 2021-01-03 00:45

Before you start shooting me down i have checked for answers and i have googled till my fingers bled but i havent been able to find a simple, concise answer. So im asking ag

相关标签:
3条回答
  • 2021-01-03 01:25

    The way i got this to work is as follows: i wrote a jsni method to open a new window

    public static native BodyElement getBodyElement() /*-{
            var win = window.open("", "win", "width=940,height=400,status=1,resizeable=1,scrollbars=1"); // a window object
            win.document.open("text/html", "replace");
    

    i added a basic body to the new window and returned the body element

    win.document.write("<HTML><HEAD>"+css1+css2+"</HEAD><BODY><div class=\"mainpanel\"><div style=\"width: 100%; height: 54px;\"><div id=\"mainbody\"class=\"mainbody\" style=\"width: 100%;\"></div></div></div></BODY></HTML>");
            win.document.close(); 
            win.focus();
            return win.document.body;
        }-*/;
    

    i then called this method from my main java method

    BodyElement bdElement = getBodyElement();
    

    I then injected my panel which has lots of widgets into the returned body element

    SystemConfiguration config = new SystemConfiguration();             bdElement.getOwnerDocument().getElementById("mainbody").appendChild(config.getElement());
    
    0 讨论(0)
  • 2021-01-03 01:36

    I agree with Bogdan: Use a DialogBox.

    If you can't, you Window.open() as you mentioned in option 1:

    1. Create another GWT module, and form.html that will load it
    2. Window.open("form.html?entry=54")
    3. Have the form gwt module read from the URL, load the entry, allow it to be edited, and provide Save and Cancel buttons
    4. Close the popup when Save or Cancel is clicked
    0 讨论(0)
  • 2021-01-03 01:49

    Can't you just use a DialogBox?

    Example

    0 讨论(0)
提交回复
热议问题