I need to use the same style in a few UI Binder templates so I did everything as described in: https://developers.google.com/web-toolkit/doc/latest/DevGuideUiBinder#Using_an_external_resource .
So I did the following:
1. Created Resources interface:
public interface Resources extends ClientBundle { @Source("shared.css") Style style(); public interface Style extends CssResource { String grayedOut(); } }
2. Created shared.css
file in the same directory as Resources class:
.grayedOut{ background-color: red; }
3. Added with
element to UI Binder template:
<ui:with type="correct.package.Resources" field="res"/>
4. Added reference to style in UI Binder template: addStyleNames="{res.style.grayedOut}"
However it doesn't work. The view is rendered just as grayedOut style wasn't applied at all.
But I observed two things:
- In Firebug/Chrome Dev Tools I can see that element has assigned an ofuscated style name corresponding to the style I'm trying to add:
class="GAWERH0MI gwt-TabLayoutPanelContent"
(GAWERH0MI
seem to correspond to mygrayedOut
class) but I can't locate it in "element styles" panel which probably means that this class is empty (no body). (I did experiment and assigned empty class to element with the same effect in that tools). - When I change style name in .css, then I'm getting runtime error that style
grayedOut
couldn't be found, which seem to mean that my style class is normally successfully found but from some reason doesn't work as expected.