从其他视图更新UI(Vaadin版本7.7.12)

问题描述 投票:0回答:1

当前,我面临着从另一种情况下更新UI的问题,场景如下

public class myWindow extends Window{

private UI ui;

@Autowired
private AbcPresenter abcpresenter;

@Override
    public void attach() {
        super.attach();
        ui = getUI();
    }

private void saveData(){
    ui.setPollInterval(1000);
        mainUI.showSpinner();//Vaadin progressbar setting visible true
         abcpresenter.saveData(param,param);
         UI.setCurrent(ui);
        close();
}

public void notifyUsers(){
try{
ui.access(() -> {
           mainUI. .hideSpinner();//hide vaadin progress bar
            Notification.show("Task done"));
        });
}catch(Exception e){
    e.printStackTrace();
}

}   

}

//here is my presenter
public class AbcPresenter(){

@Async
public void saveData(args...){
    //saving action done then notify again to myWindow class
    myWindow.notifyUsers();

}

问题仍然存在,就像它可以正常工作,如果我在当前视图中,但是如果我导航到其他视图,我将无法收到通知。!! >>

@ Async可能有问题吗?

我担心线程无法通信,因为根据代码,它将是2个线程,就像缺少某些东西一样,因为该过程一开始并且用户导航到其他用户,就不会向服务器发出UI更新请求视图(我有一个侧边栏,从中可以从当前视图导航到其他视图(该进程在后台运行),我看不到通知。

我怀疑以下事情.. !!1)关闭窗口(我正在调用notify方法)2)@异步注释3)用于服务器更新的线程之间的通信

[目前,我面临着从另一个视图更新UI的问题,方案如下:公共类myWindow扩展Window {私有UI ui; @Autowired私人AbcPresenter abcpresenter; @ ...

vaadin vaadin7
1个回答
0
投票

我通过多次尝试和错误解决了这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.