gwt表单:请求发送和到达,但在gwt中没有响应

时间:2013-03-23 10:12:48

标签: java gwt formpanel

我必须错过一些简单的东西,但我被困住了。 我在gwt中创建了一个FormPanel,根据firebug发送请求。 链接工作,因为我从firebug复制了requestlink并在浏览器窗口中原生地尝试了它。 是的,客户端和服务器主机是相同的 - >本地主机。 但答案并未达到gwt。甚至连客户端浏览器 - firebug也没有显示结果。

这是我的小形式:

    Button form = new Button ("SendForm", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            logger.log(Level.FINER, "Creating SubmitForm...");

            TextBox cmd = new TextBox();
            cmd.setName("cmd");
            cmd.setText("GetMenuitemList");

            Button sendbutton = new Button("Senden");
            logger.log(Level.FINEST, "Creating grid...");
            Grid grid = new Grid(1, 2);
            grid.setWidget(0, 0, new  Label("Command"));
            grid.setWidget(0, 1, cmd);

            VerticalPanel vPan = new VerticalPanel();
            //vPan.add(grid);
            vPan.add(sendbutton);

            logger.log(Level.FINEST, "Creating FormPanel...");
            final FormPanel formPan = new FormPanel();
            formPan.setMethod(FormPanel.METHOD_POST);
            formPan.setAction(RequestHelper.getLink("Menu.php"));

            logger.log(Level.FINEST, "Binding Send button...");
            logger.log(Level.FINEST, "Binding SubmitHandler...");
            formPan.addSubmitHandler(new SubmitHandler() {

                @Override
                public void onSubmit(SubmitEvent event) {
                    OptionPane.showMessageDialog("Form submit", event.toDebugString(), MessageType.INFO, true);
                }
            });

            logger.log(Level.FINEST, "Binding SubmitCompleteHandler...");
            formPan.addSubmitCompleteHandler(new SubmitCompleteHandler() {

                @Override
                public void onSubmitComplete(SubmitCompleteEvent event) {
                    OptionPane.showMessageDialog("Form SubmitComplete", event.toDebugString(), MessageType.INFO, true);
                }
            });

            logger.log(Level.FINEST, "Adding grid to formpan...");
            formPan.add(grid);
            formPan.add(vPan);

            logger.log(Level.FINEST, "Creating DialogBox...");
            final DialogBox box = OptionPane.createClosableBox("TestForm", true);

            sendbutton.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    formPan.submit();
                    box.hide();
                }
            });

            box.add(formPan);
            box.center();
        }
    });

预期答案如下:

{"sessionid":"6dbqibo25e0bn46fldqh37psj5","data":[{"title":"Start","Controller":"Start","Action":"Index","tooltip":"Startseite, Begr\u00fc\u00dfung","prefetch":"1"},{"title":"Register","Controller":"Person","Action":"Index","tooltip":"Neue Benutzer registrieren","prefetch":"0"},{"title":"Daten","Controller":"Contact","Action":"Index","tooltip":"Die eigenen Daten bearbeiten","prefetch":"1"},{"title":"Teilnehmerlisten","Controller":"Lists","Action":"Index","tooltip":"Listen der registrierten Benutzer","prefetch":"0"},{"title":"Suche","Controller":"Search","Action":"Index","tooltip":"Namenssuche nach Benutzer mit Kontaktm\u00f6glichkeit","prefetch":"1"},{"title":"Kalender","Controller":"Calendar","Action":"Index","tooltip":"Termine","prefetch":"1"},{"title":"Newsletter","Controller":"Newsletter","Action":"Index","tooltip":"Verschicken von Newslettern","prefetch":"1"},{"title":"Wettk\u00e4mpfer","Controller":"Competitor","Action":"Index","tooltip":"Zugriff auf Wettk\u00e4mpfer","prefetch":"1"},{"title":"Upload","Controller":"Upload","Action":"Index","tooltip":"Bilder, Videos o.\u00e4. hochladen","prefetch":"0"},{"title":"Administration","Controller":"Admin","Action":"Index","tooltip":"Datenbankfunktionen und Benutzerrechte","prefetch":"1"}]}

那么,这里出了什么问题?

顺便说一下,我会将这种技术用于登录表单。我读过,比通过RequestBuilder(已经有效)的表单更好。文件上传将在稍后发布,因此表格问题无论如何都需要答案......

提前谢谢你。 马库斯

编辑:好的,我在Chromium,Konqueror和Opera上测试过 - 代码可以运行。这只是firefox。有想法让它与Firefox一起运行? 我是eclipse和gwt的新手...也许是一些编译选项?

1 个答案:

答案 0 :(得分:0)

我自己找到并解决了这个问题:在执行form.submit之后,我隐藏了表单面板。 这是不允许的,因为javadoc说:

  

在提交完成之前,不得分离FormPanel(即从其父级删除或以其他方式从RootPanel断开连接)。否则,提交通知将失败。