GWT中的表单提交错误
我的代码是GWT中的表单提交错误,gwt,Gwt,我的代码是 FormPanel form =new FormPanel(); VerticalPanel holder = new VerticalPanel(); holder.add(new Label("User ID")); nameTextBox = new TextBox(); nameTextBox.setName("userid"); h
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不是一个函数
请告诉我正确的方法。只需添加form.setAction(“/pathfthesubmission”)
或者,如果您发送了文件,也可以添加以下内容:
form.setEncoding(FormPanel.ENCODING\u MULTIPART);
form.setMethod(FormPanel.METHOD_POST) 您使用的是哪个版本的gwt,请给我“Form”class.import.com.google.gwt.user.client.ui.FormPanel的导入语句;在您的代码中,您提到了“Form Form=new Form();”(代码的第一行)。但是您正在导入Formpanel。请您澄清一下,也可以调用Form.setAction(“您的URL”)方法。