开发者

GWT 2.0 & CSS Resource Bundles

I have a GWT 2.0 ToggleButton that I have styled from a ResourceBundle:

ToggleButton tb = new ToggleButton();
tb.setStyleName(MyResources.INSTANCE.MyCssResource().TogBut());

The client side implementation then adds additional styles to the "TogBut-up" and "TogBut-down" for the styling of the states of the button.

I can't however add a style like "TogBut-down" to my css because that is an invalid name for a field in my CssResource subclass interface.

Does anyone know what best practice is in this scenario? Should I just avoid obfuscation and resource bundles all 开发者_StackOverflowtogether?


You can use whatever css class names that you want by using the @ClassName annotation

String TogBut();
@ClassName("TogBut-up")
String TogButUp();
@ClassName("TogBut-down")
String TogButDown();

In the css you have:

.TogBut{
 ...
}
.TogBut-up{
 ...
}
.TogBut-down{
 ...
}

Google's docs about this: http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#Constants


What I ended up having to do was create multiple styles for the different states, so my bundle contained methods like this:

String TogBut();
String TogButUp();
String TogButDown();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜