【问题标题】:Is it possible to update components of a vaadin modal window?是否可以更新 vaadin 模式窗口的组件?
【发布时间】:2016-11-27 12:33:46
【问题描述】:

在 java swing 中,我习惯于为长时间运行的任务显示模式对话框。后台线程不时更新对话框上的状态标签和进度条。

使用 vaadin 模态窗口,我无法从后台线程更改任何内容,我什至无法关闭窗口。

这是预期的行为还是我做错了?

编辑:实际上我似乎无法更新窗口,即使它是非模态的。

Window window = new Window();
// window.setModal(true);

VerticalLayout layout = new VerticalLayout();
Label label = new Label("0");
layout.addComponent(label);
window.setContent(layout);
window.center();

new Thread(() -> {
  try
  {
    Thread.sleep(1000);
    System.out.println("update 1");
    UI.getCurrent().access(() -> label.setValue("1"));
    Thread.sleep(1000);
    System.out.println("update 2");
    UI.getCurrent().access(() -> label.setValue("2"));
    Thread.sleep(1000);
    System.out.println("update 3");
    UI.getCurrent().access(() -> label.setValue("3"));
    Thread.sleep(1000);
    System.out.println("close");
    UI.getCurrent().access(() -> window.close());
  }
  catch(InterruptedException e)
  {
    System.out.println(e);
  }
}).start();

UI.getCurrent().addWindow(window);

编辑 2:我刚刚偶然发现了 vaadin push concept,这可能是我在这里所缺少的。

【问题讨论】:

    标签: vaadin vaadin7


    【解决方案1】:

    原因是我没有配置vaadin push

    在我的主 UI 中添加 vaadin-push 依赖和 @Push 注解后,它开始工作了。

    现在转到next problem...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-13
      • 2021-10-15
      相关资源
      最近更新 更多