Hi,
I am trying to get a LoginScreen. Therefore i want to map two UIs to the root path:
LoginUI = /* (this is the initial UI)
MainUI = /* (This is UI ui after successful login in)
I have a lot of problems get this to work with spring-boot:
My UIProvider is ignored!
public class MyUIProvider extends UIProvider
@Override
public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
return VaadinSession.getCurrent().getAttribute(LoginUI.LOGIN_USER_ID) == null ? LoginUI.class : MainUI.class;
}
@Override
public UI createInstance(UICreateEvent event) {
UI instance = new LoginUI();
springHelper.getCtx().getAutowireCapableBeanFactory().autowireBean(instance);
return instance;
}
}
SprngVaadinServler
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = LoginUI.class)
public class MySpringVaadinServlet extends SpringVaadinServlet implements SessionInitListener {
private static final Logger LOG = LoggerFactory.getLogger(CustomSpringVaadinServlet.class);
@Autowired
MyUIProvider uiProvider;
@Override
public void init(ServletConfig servletConfig) throws ServletException {
super.init(servletConfig);
AutowireCapableBeanFactory ctx =
((ApplicationContext) getServletContext().getAttribute("applicationContext"))
.getAutowireCapableBeanFactory();
ctx.autowireBean(this);
}
@Override
protected void servletInitialized() throws ServletException {
getService().addSessionInitListener(this);
}
@Override
public void sessionInit(SessionInitEvent event) throws ServiceException {
event.getSession().addUIProvider(uiProvider);
}
}