GWT中的表单提交错误

时间:2009-10-27 07:58:03

标签: gwt

我的代码是

            FormPanel form =new FormPanel();
            VerticalPanel holder = new VerticalPanel();
            holder.add(new Label("User ID"));
            nameTextBox = new TextBox();
            nameTextBox.setName("userid");
            holder.add(nameTextBox);

             submitButton = new Button("Submit");
             holder.add(submitButton);
            form.add(holder);

            submitButton.addClickListener(new ClickListener() {

            @Override
            public void onClick(Widget sender) {
                    form.submit();
            }

            });

            form.addFormHandler(new FormHandler() {
                    public void onSubmit(FormSubmitEvent event) {


           }

           public void onSubmitComplete(FormSubmitCompleteEvent event) {

        }
      });

但是当我提交表格时我会收到错误

[错误]未捕获的异常已转义 com.google.gwt.core.client.JavaScriptException:(TypeError):form.submit不是函数

请告诉我正确的方法..

1 个答案:

答案 0 :(得分:1)

只需添加form.setAction(“/ pathofthesubmission”);

或者如果您发送文件,还要添加以下内容:

form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST);