【问题标题】:Sending response to the formpanel in gwt from servlet从 servlet 向 gwt 中的窗体面板发送响应
【发布时间】:2011-06-21 06:40:25
【问题描述】:

我正在从 gwt 客户端程序调用 servlet 并设置

final FormPanel form = new FormPanel();
form.setMethod(FormPanel.METHOD_POST);
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setAction(GWT.getModuleBaseURL()+"/uploadservlet2");

现在提交完成后,我想在这个事件中从 servlet 中检索一个参数,

 form.addFormHandler(new FormHandler() {
      public void onSubmit(FormSubmitEvent event) {
        // This event is fired just before the form is submitted. We can take
        // this opportunity to perform validation.
                RootPanel.get().add(new Label("On submit"));
      }

      public void onSubmitComplete(FormSubmitCompleteEvent event) {
**///I want parameter here**
                RootPanel.get().add(new Label("On submiting complete"));
      }
    });

请告诉我该怎么做。

【问题讨论】:

    标签: gwt servlets


    【解决方案1】:

    在您的 onSubmitComplete 中:

    public void onSubmitComplete(FormSubmitCompleteEvent event) {
    String serverResponse = event.getResults();
    
    }
    

    您可以让服务器返回 HTML 并将其放入 HTML 小部件中,或者让服务器返回 som JSON 并在 GWT 中解析。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-06
      • 2011-09-21
      • 1970-01-01
      • 1970-01-01
      • 2015-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多