我正在尝试使用 vaadin 中的复习插件。但刷新方法永远不会被执行。我错过了什么?
@VaadinUI
@PreserveOnRefresh
public class RootUI extends UI {
@Override
protected void init(VaadinRequest request) {
REFRESHER.setRefreshInterval(500);
REFRESHER.addListener(new ChatRefreshListener());
addExtension(REFRESHER);
}
public static final Refresher REFRESHER = new Refresher();
public class ChatRefreshListener implements RefreshListener {
@Override
public void refresh(final Refresher source) {
System.out.println("test"); //this is never executed
}
}
}
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class MyApp extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(MyApp.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(MyApp.class);
}
}
<vaadin.version>7.4.0.alpha2</vaadin.version>
最佳答案
首先,在常量中使用扩展充其量是非常危险的,但很可能根本不起作用。
但最重要的是,我已弃用 Refresher,转而使用 UI.setPollInterval()
这是在 Vaadin 7.1 中引入的。 Vaadin 7.2(我认为)引入了 PollListener
,因此您现在也可以获得每个民意调查的事件。
既然 Refresher 最终 100% 集成到 Vaadin 中,我想我应该明确表示弃用。
关于java - 如何在 vaadin 中使用复习插件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24362405/