How to access UI httprequest without loading the theme

Hi,

I have an app, vaadin 7.6, user client IE, it has two vaadin themes. The app reads login-user token from httprequest, then display the applictaion. When we read from httprequest, we also get the information of which theme this user prefers to use, then we set the theme to display. Technically this works, what we need is

@Theme(“theme1”) ← this is the problem
public class MyUI extends UI …
{

@Override
protected void init(VaadinRequest request)
{
thisUsuer = myAuthenticate(request);
if(thisUser.getTheme() == 1)
setTheme(“theme1”);
else
setTheme(“theme2”);
}
}

The problem is from @Theme(“theme1”). This guy is loaded before init. So if user uses theme2, we will see the waiting cursor of theme1, then waiting cursor of theme2, then app is loaded. The biggest problem is this loading order will mess up our DOM. I cannot leave out @Theme(“theme1”), because then default Vaadin theme will be loaded, which also mess up DOM.

What I would like to do is: read httprequest, then init UI based on theme. So there will be one and only one theme being loaded which is user’s preference. Is that possible?

BR,
Xuan

I think what you need is a custom uiprovider, check here https://vaadin.com/docs/v7/framework/application/application-environment.html

You have two UI classes with different themes and inside the uiprovider, you can choose which UI to use according to http request.