Hi
I'm attempting to create a composite widget, which will show a 'list' of child widgets, but I'm having some trouble getting css to work in this setting. Have constructed a simple demo, to try and figure out a solution. Have tried to specify the parent widget like this
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<ui:with field='res' type='egov.widgets.discussion.client.poc.Resources' />
<g:FlowPanel ui:field="childPanel" stylePrimaryName='{res.style.parentStyle}'>
</g:FlowPanel>
</ui:UiBinder>
with code
public class CssParent extends Composite{
interface MyUiBinder extends UiBinder<Widget, CssParent> {}
private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
@UiField FlowPanel childPanel;
public CssParent() {
initWidget(uiBinder.createAndBindUi(this));
CssChild child = new CssChild();
childPanel.add(child);
}
}
the child widget is simply specified as
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<ui:with field='res' type='egov.widgets.discussion.client.poc.Resources' />
<g:HTMLPanel stylePrimaryName='{res.style.childStyle}'>
Howdy folks
</g:HTMLPanel>
</ui:UiBinder>
now, as you can see they both reference a resource bundle:
public interface Resources extends ClientBundle {
@Source("CssDemo.css")
Style style();
public interface Style extends CssResource{
String parentStyle();
String childStyle();
}
}
which again references CssDemo.css: .parentStyle{ background-color: grey; }
.parentStyle .childStyle{
background-color: yellow;
}
but for some reason these css rules are never applied to the two div elements above. Any idea as to why this fails? Or a better way of sharing a .css style sheets between widgets, when the styles include dependency-rules between different css classes?