java gwt 文本框添加更改处理程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2615745/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 22:01:53  来源:igfitidea点击:

gwt textbox add change handler

javagwttextbox

提问by msaif

i have a textbox received from designer.but i wrote action in GWT. the problem is textbox is empty but when textbox is filled by value by pressing button then alert box will be displayed informed that value has been changed. but not worked.help me.

我有一个从设计师那里收到的文本框。但我在 GWT 中写了动作。问题是文本框是空的,但是当文本框通过按下按钮被值填充时,将显示警报框,通知值已更改。但没有用。帮帮我。

  TextBox zip1 = null;

  function onModuleLoad() {
    zip1 = TextBox.wrap(DOM.getElementById("zip1"));
    zip1.addChangeHandler(zip1ChangeAction());
 }

private ChangeHandler zip1ChangeAction() {
   return new ChangeHandler() {
      public void onChange(ChangeEvent event) {
         Window.alert("change fired");
      }
   };
}

回答by Igor Klimer

It seems that what you want is ValueChangeHandler:

看来你想要的是ValueChangeHandler

textBox.addValueChangeHandler(new ValueChangeHandler<String>() {
    @Override
    public void onValueChange(ValueChangeEvent<String> event) {
        // TODO Auto-generated method stub

    }
});