Vaadin 向导插件事件触发两次
Vaadin wizard addon event fire twice
我正在使用 Vaadin 向导插件,但遇到以下情况时遇到问题:
当用户只按forward/next步时,没有问题。但是,如果用户想转到上一步,我不小心将 Button click 监听器添加到同一个事件(这是我的假设。我调试了程序,看到如果用户转到上一页,事件发射两次)
我曾尝试在转到下一页之前删除事件侦听器,但是,我找不到一次删除所有事件侦听器的方法。另外,我不知道在哪里删除它们,因为我找不到在 Vaadin 向导中将用户移动到下一页之前执行的函数。
我正在关注这个例子:
是否有删除所有 ClickListener 的方法?
如果存在,我应该在哪里添加该功能?
此外,我也在使用 ListDataProvider
和 NativeSelect
组件。
NativeSelect 有 HasValue.ValueChangeListener<String>
侦听器,在默认实现中,我找不到可以使用的方法:
NativeSelect<String> select = new NativeSelect<>("List");
select.addValueChangeListener(new HasValue.ValueChangeListener<String>() {
// some overwritten valuechange method
}
select.removeValueChangeListener(); // This does not exist
我正在 public Component getContent() {}
方法中设置点击监听器
在 Vaadin 8 中,您需要使用 Registration interface 删除监听器。
添加监听器时,它将return注册:
final Registration registration = select.addValueChangeListener(this::doSomething);
然后删除它:
registration.remove();
我正在使用 Vaadin 向导插件,但遇到以下情况时遇到问题:
当用户只按forward/next步时,没有问题。但是,如果用户想转到上一步,我不小心将 Button click 监听器添加到同一个事件(这是我的假设。我调试了程序,看到如果用户转到上一页,事件发射两次)
我曾尝试在转到下一页之前删除事件侦听器,但是,我找不到一次删除所有事件侦听器的方法。另外,我不知道在哪里删除它们,因为我找不到在 Vaadin 向导中将用户移动到下一页之前执行的函数。
我正在关注这个例子:
是否有删除所有 ClickListener 的方法?
如果存在,我应该在哪里添加该功能?
此外,我也在使用 ListDataProvider
和 NativeSelect
组件。
NativeSelect 有 HasValue.ValueChangeListener<String>
侦听器,在默认实现中,我找不到可以使用的方法:
NativeSelect<String> select = new NativeSelect<>("List");
select.addValueChangeListener(new HasValue.ValueChangeListener<String>() {
// some overwritten valuechange method
}
select.removeValueChangeListener(); // This does not exist
我正在 public Component getContent() {}
方法中设置点击监听器
在 Vaadin 8 中,您需要使用 Registration interface 删除监听器。
添加监听器时,它将return注册:
final Registration registration = select.addValueChangeListener(this::doSomething);
然后删除它:
registration.remove();