从servlet发送对gwt中的formpanel的响应

时间:2011-06-21 06:40:26

标签: gwt servlets

我从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"));
      }
    });

请告诉我如何做到这一点。

1 个答案:

答案 0 :(得分:2)

你的onSubmitComplete中的

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

}

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