|
Page Edited :
WICKET :
How to load an external image
How to load an external image has been edited by Boris Berkman (Jan 04, 2007). Content:How can I load an image directly from a url? For example I want to display a picture of a user next to their profile, class StaticImage extends WebComponent {
public StaticImage(String id, IModel model) {
super(id, model);
}
protected void onComponentTag(ComponentTag tag) {
checkComponentTag(tag, "img");
tag.put("src", getModelObjectAsString());
}
}
add(new StaticImage("img", new Model("http://foo.com/bar.gif"));
Thanks to Igor Vaynberg ==================================================================== Even with the code above it wasn't obvious for us how to create clickable icons public class GridThumbnailPanel extends Panel { public GridThumbnailPanel( String id, String label, String iconURL, String linkURL) { super( id); Label label = new Label( "label", label); add( label); StaticImage img=new StaticImage( "icon", new Model(iconURL)); ExternalLink link=new ExternalLink( "link", linkURL); link.add(img); add( link); } } <wicket:panel>
<div wicket:id="label">[test]</div>
<a wicket:id="link" target="_blank"> <img wicket:id="icon"/> </a>
</wicket:panel>
Please, notice that our panel consists of a label and an icon. To construct |
Unsubscribe or edit your notifications preferences
