Hello All,
I’m a little bit confused about using multiple UI in the same application.
I made a few tests and never got it to work.
According to documentation, in Vaadin7, we can manage multiple UIs in the same application, they sould all share the same session. According to my tests, the session is never the same.
A quick and dirty test was :
One principal UI :
public class Vaadin_testUI extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(
productionMode = false,
ui = Vaadin_testUI.class)
public static class testUIServlet extends VaadinServlet
{
}
Table table;
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.addComponent(new Label("MainUI"));
setContent(layout);
}
}
Then a secondary UI :
public class ExternalWindowUI extends UI
{
@WebServlet(value = "/external/*", asyncSupported = true)
@VaadinServletConfiguration(
productionMode = false,
ui = ExternalWindowUI.class)
public static class MyProjectServlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request)
{
VerticalLayout vLayout = new VerticalLayout();
vLayout.addComponent(new Label("TEST"));
Button btn = new Button("TEST");
btn.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
Notification.show("UIs : " + getSession().getUIs().size());
}
});
vLayout.addComponent(btn);
setContent(vLayout);
}
}
Calling main UI in the browser shows me the “MainUI”
Calling secondary UI in another tab in the browser shows me “TEST” button.
Both UI are working. But if I click the button, i expect to get “UIs : 2” (main and secondary). Instead I’m getting “UIs : 1”
If I debug and check getSession() values on each UIs, they are different.
What am I missing here ?
Regards
Sebastien