I'm trying to create a separate Button css class, that should be accessible by a ClientBundle
. My goal is to change button styles programmatically by application state.
The following applies the button style, but does not change the background, so somehow the -ok
dependent stylename is not taken into account. Why?
.myButton {
background: white;
}
.myButton-ok {
background: green;
}
public interface MyButtonResource extends ClientBundle {
public static final MyButtonResource INSTANCE = GWT.create(MyButtonResource.class);
@Source("MyButtonResource.css")
Style css();
interface Style extends CssResource {
@ClassName("myButton")
String buttonStyle();
@ClassName("myButton-ok")
String buttonStyleOK();
}
}
MyButtonResource.INSTANCE.css().ensureInjected();
setStyleName(MyButtonResource.INSTANCE.css().buttonStyle());
button.addStyleDependentName(MyButtonResource.INSTANCE.css().buttonStyleOK());