首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未定义FormPanel "addFormPanel“方法

未定义FormPanel "addFormPanel“方法
EN

Stack Overflow用户
提问于 2012-01-15 11:46:03
回答 1查看 297关注 0票数 1

在web上有很多关于这类代码的示例:

代码语言:javascript
复制
    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

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-01-15 14:49:06

在web上有很多这类代码的示例:

你在哪里见过这样的例子?

我认为,在FormPanel(在更早的(1.62.1,甚至在2.3中))中没有这样的方法,如果你想添加onSubmit和/或onSubmitComplete处理程序,只需执行文档中给出的相同操作:

代码语言:javascript
复制
// 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());
      }
    });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8867391

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档