Hi all,
I am trying to send a message from a Spring Service to a Vaadin View using “ru.xpoft.vaadin” plugin.
All my views and UI are working using prototype scope, but when I try to send a message from a service “singleton scope” to my view it gets null for the current UI.
Is there any reason for it? UI.getCurrent() returns null.
I’d appreciate any help.
For example:
@Service
class service{
public void send(){
Broadcaster.broadcast(“miau”);
}
}
@Component
@Scope(SCOPE_PROTOTYPE)
@VaadinView(value = “myView”)
class MyView implements BroadcastListener{
@PostConstruct
public void init() {
Broadcaster.register(this);
}
@Override
public void receiveBroadcast(final String message) {
UI.getCurrent().access(new Runnable() {
@Override
public void run() {
LOGGER.info(Thread.currentThread().getName() + ": " + message);
}
});
}
@Override
public void detach() {
Broadcaster.unregister(this);
}
}