I'm new to GWT; I'm building a small sample app. I have several CSS files. I'm able to successfully use the ClientBundle and CssResource to assign styles to the elements defined in my UiBinder script.
Now I'd like to take it one step further and introduce CSS constants using @def css-rule. The @def works great when I define a constant and use it in the same CSS file. However I cannot use it in another CSS file. When I try to use the @eval rule to evaluate an existing constant the compiler throws an execption: "cannot make a static reference to the non-static method ".
Here is an example of what I'm trying to do:
@def BACKGROUND red;
package abc;
import ...;
interface ConstantStyle extends cssResource {
String BACKGROUND();
}
@eval BACKGROUND abc.ConstantStyle.BACKGROUND();
.myClass {background-color: BACKGROUND;}
package abc;
import ...;
interface ConstantStyle extends cssResource {
String myClass;
}
package abc;
import ...;
interface MyResources extends ClientBundle {
@Source("ConstantStyle.css")
ConstantStyle constantStyle();
@Source("MyStyle.css")
MyStyle myStyle();
}
Thanks in advance!
Add "ConstantStyle.css" to the @Source annotation in ClientBundle like this:
package abc;
import ...;
interface MyResources extends ClientBundle {
@Source("ConstantStyle.css")
ConstantStyle constantStyle();
@Source({"ConstantStyle.css", "MyStyle.css"})
MyStyle myStyle();
}
It does the same as would @import "ConstantStyle.css" in MyStyle.css (except @import is ignored by GWT I believe).
You don't need @eval.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With