用GWT中的Widget打开一个新窗口 [英] Opening a new Window with a Widget in GWT

查看:124
本文介绍了用GWT中的Widget打开一个新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在你开始拍摄我之前,我已经检查了答案,并且我已经使用了Google,直到我的手指流血,但是我还没有找到简单,简明的答案。所以我再次询问所有可能有这个问题的人。



问题:如何用一个formpanel打开一个新窗口。



上下文:我有一个列出大量项目的应用程序,我希望有人编辑条目,我想要打开一个新窗口,可以编辑属性,然后点击保存。一个标准的东西,你在很多应用程序中找到。



架构:
我有一个名为UI的客户端模块,从菜单中选择时,可以绘制小部件并填充主区域。我有一个名为UI.html的HTML页面,头部有标签。这就是它。



选项我看过


  1. 调用 Window.Open(),但您需要定义一个html文件。我没有。我可以创建一个空的

  2. 使用 jsni $ wnd 创建一个新窗口并获得对它的引用。但是,我如何在其中注入一个表单面板? 使用 popuppanel
  3. 他们看起来很烂 - 再加上如果通过JS打开一个窗口非常简单,我预计它会在gwt中。


也许我很想知道如何使用GWT我不知道。



任何帮助将不胜感激



谢谢

p>

解决方案

我得到这个工作的方式如下:
i写了一个jsni方法来打开一个新窗口

  public static native BodyElement getBodyElement()/ *  -  {
var win = window.open(,win, WIDTH = 940,高度= 400,状态= 1,可调整大小= 1,滚动条= 1); //一个窗口对象
win.document.open(text / html,replace);

我在新窗口中添加了一个基本主体并返回了主体元素

'pre> win.document.write( < HTML>< HEAD> 中+ CSS1 + CSS2 +< / HEAD>< BODY>< DIV class = \mainpanel \>< div style = \width:100%; height:54px; \>< div id = \mainbody \class = \主体\style = \width:100%; \>< / div>< / div>< / div>< / BODY>< / HTML>);
win.document.close();
win.focus();
return win.document.body;
} - * /;

然后我从我的主要java方法调用这个方法

  BodyElement bdElement = getBodyElement(); 

然后我的面板中有很多小部件插入到返回的body元素中

  SystemConfiguration config = new SystemConfiguration(); 。bdElement.getOwnerDocument()的getElementById( 型主体)的appendChild(config.getElement())。 


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 again for all those that might have this problem.

Question: how to open a new window with a formpanel in side.

Context: i have an app that lists lots of items, i want someone to edit an entry, i want a new window to open so they can edit properties then hit save. A standard thing you find in a lot of applications.

Architecture: I have one client module called UI, it has a dozen classes that draw widgets and fill a main area when selected from a menu. I have a single html page called UI.html which has the tag in the head. Thats it.

Options Ive Seen

  1. Call Window.Open() but you need to define a html file. I dont have one. I can create an empty one but how do you inject a widget in to it ?

  2. use jsni $wnd to create a new window and get a reference to it. But how do i inject a form panel into it ??

  3. use a popuppanel. They look sucky - plus if opening a window through JS is quite simple i would expect it to be in gwt.

Maybe im miss understanding how to use GWT i dont know.

Any help would be appreciated

Thanks

解决方案

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());

这篇关于用GWT中的Widget打开一个新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆