I'd suggest using Anchor
, more specifically, via the Anchor(java.lang.String text)
constructor:
Creates an anchor for scripting. The
anchor's href is set to javascript:;,
based on the expectation that
listeners will be added to the anchor.
So, you'll get a good ol' <a>
that on click doesn't do anything, but you can add a ClickHandler
to it, as such:
Anchor anchor = new Anchor("Click me!"); // At this point clicking it won't do a thing
anchor.addClickHandler(new ClickHandler() {
@Override
public void onClick (ClickEvent event){
Window.open("http://www.example.com/", "_blank", ""); // Or open a PopupPanel
// or sth similar
}
});
I'm advising Anchor
over Label
for accessibility reasons - if it's a link, then it should be an <a>
, IMHO. If you really need to use a Label
, you can add to it a ClickHandler
like shown above.