Skip to content
Advertisement

Wicket: how to create ExternalLink with

Within a table cell, I have to create a Wicket ExternalLink that shows the response in a new browser tab. I’ve used this code (Wicket 7.9):

JavaScript

But Wicket renders this:
<div onclick="window.location.href='http://www.geodata.com/maps?service=WFS&amp;request=GetCapabilities';return false;" target="_blank">Caps</div>

This doesn’t open a new tab.

The tables HTML markup is generated by Wicket, so I can’t insert
<td><a wicket:id="link" href="..."></a></td> in the corresponding markup.

How can I force Wicket to render <a href=" ... " target="_blank">Caps</a> ?

Alternatively, how can I create a new browser tab when I can’t avoid using onClick (Javascript) ?

Advertisement

Answer

I solved the problem by creating an extension of Wickets Panel with this simple markup:

JavaScript

Because of <a wicket:id="link"> Wicket doesn’t create Javascript for the link.

Corresponding Java:

JavaScript

And in the code that creates the table column:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement