I'm trying to use an image from a ClientBundle
as a background-image in a UIBInder template. I used this discussion as a guide, but was unable to get it to work.
In my Java class I have:
public static interface PriceButtonStyles extends ClientBundle
{
String paidIcon();
@ClientBundle.Source("paid_button_53x31.png")
DataResource paid_buttonAsDataResource();
}
@UiField
PriceButtonStyles priceButtonStyle;
And then in the corresponding template file I reference it like:
<ui:style field="priceButtonStyle" type="com.example.client.PriceButton.PriceButtonStyles">
@url paidIconUrl paid_buttonAsDataResource;
.paidIcon {
background: paidIconUrl 0 0 no-repeat;
}
</ui:style>
Already at this point my IDE is showing the "paidIconUrl" string in red, indicating that something's not quite right:
And indeed, when I try to run it I get:
ERROR: Type com.ecample.client.PriceButton.PriceButtonStyles does not extend com.google.gwt.resources.client.CssResource Element <ui:style field='priceButtonStyle' type='com.example.client.PriceButton.PriceButtonStyles'> (:7).
ERROR: Uncaught exception escaped. com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
Further on in the Google Groups discussion it is suggested that this might work with <ui:data>
rather than <ui:style>
, so I tried to make that work. But it seems like you can't include both CSS styles (e.g. my paidIcon()
method) and DataResources in <ui:data>
resources. I wasn't able to find much documentation on <ui:data>
, so I'm really just grasping at straws with this.