use of com.vaadin.flow.component.page.Push in project flow by vaadin.
the class PushView method onAttach.
@Override
protected void onAttach(AttachEvent attachEvent) {
super.onAttach(attachEvent);
UI ui = attachEvent.getUI();
// Fallback transport is forced to websocket so that we either get a
// websocket connection or no push connection at all
ui.getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET);
add(new NativeButton("Say hello", e -> {
add(new Paragraph("Hello"));
new Thread(new SayWorld(ui)).start();
}));
}
use of com.vaadin.flow.component.page.Push in project flow by vaadin.
the class BootstrapHandler method createAndInitUI.
protected BootstrapContext createAndInitUI(Class<? extends UI> uiClass, VaadinRequest request, VaadinResponse response, VaadinSession session) {
UI ui = ReflectTools.createInstance(uiClass);
PushConfiguration pushConfiguration = ui.getPushConfiguration();
ui.getInternals().setSession(session);
ui.setLocale(session.getLocale());
BootstrapContext context = new BootstrapContext(request, response, session, ui);
Optional<Push> push = context.getPageConfigurationAnnotation(Push.class);
DeploymentConfiguration deploymentConfiguration = context.getSession().getService().getDeploymentConfiguration();
PushMode pushMode = push.map(Push::value).orElseGet(deploymentConfiguration::getPushMode);
pushConfiguration.setPushMode(pushMode);
pushConfiguration.setPushUrl(deploymentConfiguration.getPushURL());
push.map(Push::transport).ifPresent(pushConfiguration::setTransport);
// Set thread local here so it is available in init
UI.setCurrent(ui);
ui.doInit(request, session.getNextUIid());
session.addUI(ui);
// After init and adding UI to session fire init listeners.
session.getService().fireUIInitListeners(ui);
return context;
}
use of com.vaadin.flow.component.page.Push in project flow by vaadin.
the class BasicPushUI method init.
@Override
protected void init(VaadinRequest request) {
/*
* Read push settings from the UI instead of the the navigation target /
* router layout to preserve the structure of these legacy testing UIs
*/
Push push = getClass().getAnnotation(Push.class);
getPushConfiguration().setPushMode(push.value());
getPushConfiguration().setTransport(push.transport());
super.init(request);
}
Aggregations