Search code examples
gwthyperlinkuibinder

Link-widget GWT - uiBinder


I want to use a link or a button like (a href="..."/>) in GWT with uiBinder.

I found the widget "hyperlink" but I don´t know how I use that.


Solution

  • You should use the Anchor widget.

    You can use a sample ClickHandler on it to detect the click event or use the default href with the constructor :

    Anchor(boolean useDefaultHref) 
    

    You can also use the setter setHref(java.lang.String href)

    In UiBinder :

    <g:Anchor ui:field="mylink" href="/myurl">The link test</g:Anchor>
    

    EDIT :

    To open the link in a new tab, you should use the setTarget(String target) method like the following example :

    setTarget("_blank");