Why @Theme does not read the theme name from cookies?


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

public class CustomVaadinCDIServlet extends VaadinCDIServlet {

    protected VaadinServletService createServletService( DeploymentConfiguration deploymentConfiguration ) throws ServiceException {
        final VaadinCDIServletService service = new VaadinCDIServletService(this, deploymentConfiguration) {
            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;
        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 "
" is annotation attribute contains the name for cookie with vaadin theme name.


Thanks. Seems this is the only right solution.