Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a wicket link appear as an image?

Tags:

java

wicket

I am trying to make a wicket link appear as an image instead of text. I am creating an external link and then placing it on the page.

add(new ExternalLink("link", url, "Page name"));
<a wicket:id="link"></a>

My problem is that I can't put the image in place of "Page name" because it will just set the html as text. I also tried to span a wicket id instead and it also is rendered as text. Can anyone help?

like image 476
Bthunder Avatar asked Jun 18 '10 14:06

Bthunder


2 Answers

For a static image:

<a wicket:id="link"><img src="myImg.jpg" alt="My Image" /></a>
add(new ExternalLink("link", url));

Or for a dynamic image add the image to the ExternalLink

like image 126
schmimd04 Avatar answered Nov 16 '22 03:11

schmimd04


For programatically set image:

HTML:

<a wicket:id="link"><img wicket:id="img"/></a>

Java:

ExternalLink link = new ExternalLink("link", url);
Image image = new Image("img", new SharedResourceReference(BasePage.class, "images/MyImage.png")
link.add(image);
add(link);
like image 8
Ondra Žižka Avatar answered Nov 16 '22 03:11

Ondra Žižka