Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Why @Theme does not read the theme name from cookies?
Hi,
I am using some vaadin themes in my application and give the user the availability to choose one of them.
Current theme name saved in cookies.
I can not use @Theme annotation for my UI class because Vaadin try to use that annotation theme name as default in bootstrap stage.
I have to create my custom VaadinCDIServletService (I am using vaadin-cdi) and override getConfiguredTheme method:
public class CustomVaadinCDIServlet extends VaadinCDIServlet {
@Override
protected VaadinServletService createServletService( DeploymentConfiguration deploymentConfiguration ) throws ServiceException {
final VaadinCDIServletService service = new VaadinCDIServletService(this, deploymentConfiguration) {
@Override
public String getConfiguredTheme( VaadinRequest request ) {
final String theme = Cookies.get( request, Constants.VAADIN_THEME_COOKIE_NAME );
return theme != null && Themes.contains( theme ) ? theme : Themes.VALO_facebook;
}
};
service.init();
return service;
}
}
It's ugly code and, in my opinion, the best solution would be
@Theme( value="valo", themeCookieName=Constants.VAADIN_THEME_COOKIE_NAME )
where "themeCookieName" is annotation attribute contains the name for cookie with vaadin theme name.
Thanks,
Dmitry