Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何让gwt表单提交在设置了维度的新窗口中打开?_Gwt_Resize_Submit_New Window - Fatal编程技术网

如何让gwt表单提交在设置了维度的新窗口中打开?

如何让gwt表单提交在设置了维度的新窗口中打开?,gwt,resize,submit,new-window,Gwt,Resize,Submit,New Window,我正在使用GWT,我需要在一个新窗口中以设置的宽度和高度打开表单提交的结果。我可以让它在一个新的选项卡中打开,但不知道如何让它在新窗口中加载,也不知道如何设置宽度和高度。这是我的密码: @UiHandler({"myGWTButton"}) protected void myGWTButtonClicked(ClickEvent click) { click.preventDefault(); FormPanel form = new FormPanel("_b

我正在使用GWT,我需要在一个新窗口中以设置的宽度和高度打开表单提交的结果。我可以让它在一个新的选项卡中打开,但不知道如何让它在新窗口中加载,也不知道如何设置宽度和高度。这是我的密码:

 @UiHandler({"myGWTButton"})
    protected void myGWTButtonClicked(ClickEvent click) {
      click.preventDefault();
      FormPanel form = new FormPanel("_blank");
      form.setAction("www.mydomain.com");
      form.setMethod(FormPanel.METHOD_POST);
      form.setEncoding("multipart/form-data");
      TextArea params0 = new TextArea();
      params0.setName("foo");
      params0.setValue("bar");
      form.setVisible(false);
      form.add(params0);
      RootPanel.get().add(form);
      form.submit();
    }

表单似乎在单独的iframe中获得结果。问题是,由于跨站点限制(SOP),您无法真正与此iframe交互。所以我不确定有没有办法做到这一点


您不能改用HTTP请求吗?

如果您可以使用GET方法而不是POST,我有可能为您提供解决方案


似乎我试图使用GWT时考虑过了。我依靠本机javascript解决了我的问题

 @UiHandler({"myGWTButton"})
    protected void myGWTButtonClicked(ClickEvent click) {
    click.preventDefault();
    openPopupWindow("www.mydomain.com", 'bar');
}

native void openPopupWindow(String url, String val) /*-{
       var windowName = '' + Math.floor(Math.random() * 10000000) ; //we need some name to reference it later, so assign a random number as the name (make sure the number doesn't have a decimal because IE will choke on it)
       var popupWindow =  window.open('', windowName, 'width=550,height=350,resizeable,scrollbars');
       var form = document.createElement("form");
       form.setAttribute("method", "post");
       form.setAttribute("action", url);
       form.setAttribute("target", windowName);
       form.setAttribute("enctype", "multipart/form-data");
       var hiddenField = document.createElement("input");
       hiddenField.setAttribute("type", "hidden");
       hiddenField.setAttribute("name", "foo");
       hiddenField.setAttribute("value", val);
       form.appendChild(hiddenField);
       document.getElementsByTagName('body')[0].appendChild(form);
       while(!popupWindow){
         //wait for popupwindow to open before submitting the form
       }
       form.submit();

    }-*/;

谢谢你的回复。我无法使用GET,因为我发送的数据太大。@无限您是否提交到与原始页面相同的域:端口?如果否,您提交的服务器是否允许跨域请求?因为如果你对其中一些问题回答“是”,你可以提交到隐藏框架,然后你可以从原始页面访问框架结果并打开新窗口,将结果从框架传递到窗口。我确实提交到同一个域。我最终用原生javascript解决了这个问题。如果你想看的话,我已经发布了解决方案。
 @UiHandler({"myGWTButton"})
    protected void myGWTButtonClicked(ClickEvent click) {
    click.preventDefault();
    openPopupWindow("www.mydomain.com", 'bar');
}

native void openPopupWindow(String url, String val) /*-{
       var windowName = '' + Math.floor(Math.random() * 10000000) ; //we need some name to reference it later, so assign a random number as the name (make sure the number doesn't have a decimal because IE will choke on it)
       var popupWindow =  window.open('', windowName, 'width=550,height=350,resizeable,scrollbars');
       var form = document.createElement("form");
       form.setAttribute("method", "post");
       form.setAttribute("action", url);
       form.setAttribute("target", windowName);
       form.setAttribute("enctype", "multipart/form-data");
       var hiddenField = document.createElement("input");
       hiddenField.setAttribute("type", "hidden");
       hiddenField.setAttribute("name", "foo");
       hiddenField.setAttribute("value", val);
       form.appendChild(hiddenField);
       document.getElementsByTagName('body')[0].appendChild(form);
       while(!popupWindow){
         //wait for popupwindow to open before submitting the form
       }
       form.submit();

    }-*/;