membersound
membersound

Reputation: 86747

How to use refresher addon in vaadin?

I'm trying to use the refresher addon in vaadin. But the refresh method is never executed. What am I missing?

@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>

Upvotes: 2

Views: 1619

Answers (1)

Henrik Paul
Henrik Paul

Reputation: 67703

First off, using an Extension in a constant is very dangerous at best, but most probably will flat-out not work.

But most importantly, I've deprecated Refresher in favor of UI.setPollInterval() which was introduced in Vaadin 7.1. Vaadin 7.2 (I think) introduced a PollListener, so you now get events for each poll as well.

I guess I should make that deprecation explicit now that Refresher is finally 100% integrated into Vaadin.

Upvotes: 4

Related Questions