UIBinder: load background images in the bundle

It took me a while to figure this out, but finally I found a solution to load CSS background images for styles defined in a *.ui.xml:

  1. Copy the image to the same package as your *.ui.xml
  2. In the ui.xml add a “ui:data” tag that points to the image
  3. In the style block add an @url line that points to the ui:data field
  4. Use it in the style

<ui:data field=’logoImg’ src=’feederator.png’/>

<style>

@url logoUrl logoImg; 
.logo {
background: logoUrl no-repeat 0 0;
height: 55px;
    width: 250px;
}
</style>
Now a beer! Did you like this post? It often takes me several hours of my free time to write one. If I was your neighbour would you offer me a beer for the hard work I did for you? The beauty is: beers can be teletransported with a painless donation using Paypal. A beer in a Swiss bar costs about USD $4.80. Or use this affiliate link if you order something on Banggood and I'll get a small kickback. Thank you!