Search code examples
gwtsmartgwtuibinder

Use of icons inside a JAR in GWT UiBinder template


In my GWT application I also use SmartGWT library for some user interface elements. Recently I had the idea of replacing the text for some GWT Buttons (like "refresh" or "save") with an icon from SmartGWT's icon set, for example the refresh icon in /com/smartclient/theme/graphite/public/sc/skins/Graphite/images/actions/refresh.png

I tried to make the icon available in my UiBinder template with the qualified name:

    <ui:image field="refreshIcon" resource="/com/smartclient/theme/graphite/public/sc/skins/Graphite/images/actions/refresh.png" />

and use it for a PushButton:

    <g:PushButton ui:field="refreshButton" styleName="{style.Buttons}">
        <g:upFace image="{refreshIcon}" />
    </g:PushButton>

Unfortunately that does not work, eclipse has nothing to complain but when running the application I get this error:

[ERROR] [MonitoringTool] - No com.google.gwt.resources.client.ClientBundle$Source annotation and no resources found with default extensions

How can I use the bundled icons in referenced smartgwt.jar library for my PushButtons?


Solution

  • The attribute is named src, not resource:

    <ui:image field="refreshIcon" src="/com/smartclienttheme/graphite/public/sc/skins/Graphite/images/actions/refresh.png" />
    

    As a side note, it doesn't matter where the image comes from provided it's on the classpath: GWT loads everything from the classpath, whether it's in a JAR or folder doesn't matter at all.