Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    HOWTO: ImageBundles in SmartGWT Temporary Fix

    I've recently tried to use ImageBundles in SmartGWT, only to later find out that they weren't supported. My first attempt at usage involved doing the following:

    layout.addMember(new Img(Resource.ICONS.homeButton32().getUrl());

    In the case of FF and Chrome, this works fine. What you get is an IMG src that contains a base64 encoding of your image, quite ugly I must say.

    The problem arises in IE where the icons become distorted. To remedy this I've done the following:

    Add the following to your .gwt.xml:
    <set-property name="ClientBundle.enableInlining" value="false" />

    This will prevent the base64 encoded IMG src. However, this will extend the problem to IE, Chrome and FF, because all the images are bundled into a single sprite.

    In your ImageBundle, over each ImageResource add the following:
    @ImageOptions(repeatStyle=RepeatStyle.Both)

    This will prevent a sprite from being create and will instead turn all the resource into individual images. Although the intention behind the bundle is to reduce requests to your server and ease caching, these features are not supported in SmartGWT <= 2.x, I've read that support will be added in SmartGWT 3.

    I did this as a means to future proof myself for SmartGWT 3. All I'll need to do is remove the annotations and the .gwt.xml line and get rid of my calls to getURL().

    Hopefully this helps a few people.

    #2
    Firstly, thank you for your post (I realize it's 2 1/2 years old) but it let me use GWT ImageResources and still use SmartGWT.

    Has any headway been made on this?

    I'm using the latest version of SmartGWT 3.1 with the latest GWT 2.5.1 and I'd love to be able to let GWT bundle my images together.

    Comment

    Working...
    X