网上有很多这类代码的示例:
FormPanel form = FormPanel.wrap(Document.get().getElementById("login"), true);
form.setAction("javascript:;");
form.addFormPanel(new FormPanel() {
public void onSubmit(FormSubmitEvent event) {
}
public void onSubmitComplete(FormSubmitCompleteEvent event) {
}
});
但是,addFormPanel
方法未定义。
我正在使用GWT 2.1.0 BTW
有什么想法吗?
答案 0 :(得分:0)
网上有很多这类代码的示例:
你在哪里见过这样的例子?
我认为,FormPanel中没有这样的方法(早期(1.6,2.1甚至2.3)
如果您想添加onSubmit
和/或onSubmitComplete
处理程序,请执行与文档中相同的操作:
// Add an event handler to the form.
form.addSubmitHandler(new FormPanel.SubmitHandler() {
public void onSubmit(SubmitEvent event) {
// This event is fired just before the form is submitted. We can take
// this opportunity to perform validation.
if (tb.getText().length() == 0) {
Window.alert("The text box must not be empty");
event.cancel();
}
}
});
form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
public void onSubmitComplete(SubmitCompleteEvent event) {
// When the form submission is successfully completed, this event is
// fired. Assuming the service returned a response of type text/html,
// we can get the result text here (see the FormPanel documentation for
// further explanation).
Window.alert(event.getResults());
}
});