VAADIN 7:每隔5分钟刷新一次Vaadin视图的最简单方法是什么? [英] VAADIN 7: What is the simplest way to refresh a Vaadin View in 5 minute intervals?

查看:77
本文介绍了VAADIN 7:每隔5分钟刷新一次Vaadin视图的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Vaadin视图中的组件列表上实现自动刷新.该列表从数据库获取其内容.我可以使用已经实现的按钮刷新列表.

I'm trying to implement an automatic refresh on a List of components in a Vaadin view. The list gets its contents from a database. I can refresh the list with a button, that is already implemented.

但是,我想知道最简单的方法是什么,以便我已经拥有的此刷新事件将在5分钟(300 000毫秒)的时间间隔内自动刷新?

However, I would like to know what is the simplest way to make it so, that this refresh event, that I already have, would automatically refresh in 5 minute (300 000 milliseconds) intervals?

这是我尝试过的方法,即使我退出视图后它仍保持刷新,因此它实际上无法工作. 我希望仅在显示该特定视图时每隔5分钟进行一次刷新.

Here's what I tried and it keeps refreshing even after I exit the view so it doesn't really work. I'd like the refresh to happen in 5 minute intervals only while that certain view is being shown.

UI myUI = UI.getCurrent();  

            myUI.setPollInterval(300000);
            myUI.addPollListener(event -> {
                refreshList();
            });

在导航到其他视图后,如何使刷新不会发生?在Vaadin中,有没有更简单的方法可以做到这一点?谢谢

How would I make it so that the refresh doesn't happen after navigating to other views? And is there some simpler way to do this in Vaadin? Thank you

推荐答案

您可以这样做,以便致电

You could do so that you call

myUI.setPollInterval(300000);

激活视图后,您可以通过调用将其禁用

when the view is activated, and you disable it by calling

myUI.setPollInterval(-1);

当另一个视图被激活时.如果使用Vaadin Navigator,则可以使用ViewChangeListener来处理轮询.

when another view is activated. If you use Vaadin Navigator, then you could use ViewChangeListener for handling the polling.

这篇关于VAADIN 7:每隔5分钟刷新一次Vaadin视图的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆