在web上有很多关于这类代码的示例:
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
有什么想法吗?
发布于 2012-01-15 14:49:06
在web上有很多这类代码的示例:
你在哪里见过这样的例子?
我认为,在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());
}
});https://stackoverflow.com/questions/8867391
复制相似问题