CSSInject with Vaadin7

Hi all,

I am trying to migrate a Vaadin6 application into Vaadin7.
With the old Vaadin6 application, i used dynamic CSS into the java code like this :


CSSInject css = new CSSInject();
css.setValue(".v-panel-content > div { background: transparent; }.v-panel-content { background-color:"+VaadinContext.BANNER_BACKGROUND_COLOR +"; }");

This code works fine in Vaadin6, but with Vaadin7 i get the following error :
java.lang.NoClassDefFoundError: com/vaadin/terminal/Resource
This file was into vaadin-6.8.0.jar.

Do you know what to do to solve this issue ?
How to use CSSInject with Vaadin7 ?

Regards
Eric

Hi Eric. Maybe you are using the wrong version of the add-on.

Hi Alejandro,

i am using cssinject-1.0.jar with vaadin7.1

I guess you should use version 2 of CSS inject.

Ok; i replaced cssinject1.0 by cssinject2.0.3.jar in WEB-INF/lib.
My old code with cssinject1.0 was :


//Top banner with dynamic background color
CSSInject css = new CSSInject();
css.setValue(".v-panel-content > div { background: transparent; }.v-panel-content { background-color:"+VaadinContext.BANNER_BACKGROUND_COLOR +"; }");
...
layoutBanner = new VerticalLayout();
layoutBanner.addComponent(css);

new CSSInject() is replaced by new CSSInject(target), what is “target” ??
css.setValue(…) is no more possible
Is there a documentation about cssinject in the vaadin web site ??

Eric

Don’t know about documentation. I’ve never used this add-on. However, I found this snippet on the add-on’s page:

// Version 2 (for Vaadin 7)
CSSInject css = new CSSInject(getUI());
css.setStyles(".custom-style { color: rgb(100, 200, 300); }");

Hope this helps.

With Vaadin 7.1 you don’t need anymore an add-on for this. There is a built-in css injection. Take a look at this wiki page:
Dynamically injecting CSS
.