tags:

views:

982

answers:

1

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 together?

+1  A: 

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();
Matt Moriarity
Thanks, I did try this, but the GWT compiler obfuscated each of the css entries to different things, so when the ToggleBuggton added the -down style the two css classes didn't match. I ended up adding @exclude to the top of my css.
Steve
What about `MyResources.INSTANCE.MyCssResource().TogBut() + "-down"`? (can't test it atm, but if the client code adds the "-down" suffix to the obfuscated style name it should work)
Igor Klimer
@Tegan ClarkWell what I was suggesting was not adding -down to the style, but simply adding the separate style. So originally do `setStyleName(resource.TogBut())` and then later `addStyleName(resource.TogButUp())`. They won't look related in the obfuscated CSS, but they will work.
Matt Moriarity