getPage().getStyles().add() in UI.init() - styles doesn't apply. Bug?

I need to supply custom css for different users. In UI.init i do:

protected void init(VaadinRequest request) {
    getPage().getStyles().add(new ExternalResource("/static/pub/style/partner.css"));
    layout = new PartnerWindowLayout(...);

When I look in browser I see my components created on page, I see that my extra css file successfully attached to DOM (via Chrome developer tools), but my components aren’t affected by partner.css. They should.

When using Chrome’s developer tools I navigate to partner.css and add one carriage return to the end of file (or other unsignificant change), needed styles magically apply!

Am I do something wrong or this is bug?
Some refresh didn’t happen or happened not in time?

It happens on Chrome and Firefox. On IE didn’t tested.

Vaadin 7.1.7.

No ideas?

Hi, I can’t reproduce your problem with the following app:

public class StyleTest extends UI { @Override protected void init(VaadinRequest request) { getPage().getStyles().add(new ExternalResource("/foo.css")); setContent(new CssLayout(new Label("Red"))); } } foo.css:

.v-label { color: blue; } I don’t really have ideas on where the problem might be, sorry :confused:

Thanks, Johannes.
Your post pointed me to the root cause of this issue. It was not so intuitive.
Under the hood css file is served by custom servlet. And everything seemd ok, except single thing. MimetypesFileTypeMap used by servlet didn’t know about css content-type and it gave application/octet-stream for css file. Browser (both Chrome and FF) loaded the css file ok, it was visible in Developer Tools. But it was not applied to html … until I opened it using Chrome’s “Sources” tab and made arbitrary modification of that file. Just after that file was magically applied to CSS - I guess Chrome reevaluated content-type by itself.

Now I use ConfigurableMimeFileTypeMap from Spring. It knows about text/css and everything works just fine.