GWT表单:请求已发送并已到达,但GWT中没有响应



我一定是错过了一些简单的东西,但我卡住了。我在gwt中创建了一个FormPanel,根据firebug发送请求。链接可以正常工作,因为我从firebug复制了requestlink,并在浏览器窗口中进行了原生尝试。是的,客户端和服务器主机是相同的-> localhost。但答案并不在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, Begru00fcu00dfung","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 Kontaktmu00f6glichkeit","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":"Wettku00e4mpfer","Controller":"Competitor","Action":"Index","tooltip":"Zugriff auf Wettku00e4mpfer","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(已经工作)。文件上传将在稍后进行,所以表单问题无论如何都需要一个答案…

提前谢谢你。马库斯

编辑:好的,我测试了铬,Konqueror和Opera也-代码工作。只是火狐浏览器。有什么想法可以让它与firefox一起运行?我完全是eclipse和gwt的新手…也许是一些编译器选项?

我自己发现并解决了这个问题:表单后。submit被执行后,我隐藏了表单Panel。这是不允许的,因为javadoc说:

在提交完成之前,FormPanel不能被分离(即从其父面板中移除或与RootPanel断开连接)。否则,提交通知将失败。

相关内容

  • 没有找到相关文章

最新更新