<td style="background-image: url(abc.png); background-repeat: no-repeat;">
Wicket code for generating this code:
First step is to obtain the URL of the background image. Let's say this time the image is in the package (i.e. together with the Java & HTML classes for a more object-oriented approach).
PackageResourceReference bgImageResource = new PackageResourceReference(this.getClass() ,"abc.png");
String imageUrl = RequestCycle.get().urlFor(bgImageResourc e, new PageParameters()).toString();
imageUrl is the relative path from the context root to the image file. However, this URL will not work as-is, as the current page is unlikely to be on the context root.
To generate full URL:
imageUrl = RequestCycle.get().getRequest().getConte
Lastly, create the style attribute with an AttributeModifier.
tdElement.add(new AttributeModifi
No comments:
Post a Comment