Nav
Nav

Reputation: 4540

How to set background image to an ClientBundle resource in uibinder (GWT)

How to set background image in uibinder/java to an image in ClientBundle without using:

obj.getElement().getStyle().setBackgroundImage("url("+Images.INSTANCE.bg().getURL()+")");

Because this doesn't work in IE (FF is OK). I think I should set the background image directly in uibinder with css @url or ...

(I am using GWT 2.0.3)
Regards

Upvotes: 2

Views: 5030

Answers (2)

Joseph Lust
Joseph Lust

Reputation: 19985

ImageResource uses Data Urls and spriting. Sadly, older versions of IE support neither of these well. Data Url is not supported at all and on i.e. 7- a new copy of the entire sprite image is used for every clipped appearance of the image. So, if you have a sprite with 100 icons and use it in 100 places, IE will consume the memory of 100x that image.

Try to get away from really old IE if you can.

Upvotes: 0

Igor Klimer
Igor Klimer

Reputation: 15321

The docs explain this :) (note that internally UiBinder uses CssResource, so all that applies to CssResource, applies to the CSS styles you define in UiBinder's <ui:style> too)

Upvotes: 1

Related Questions