如何用GWT创建可点击链接?

时间:2011-01-22 21:19:28

标签: html gwt

我想与GWT建立一些可点击的链接。我不确定这是否是最好的做法。基本上我想要类似这样的东西,如果我用html写的

<a href="index.html" alt="">Link</a>

1 个答案:

答案 0 :(得分:12)

如果您想在应用中“链接到某个地方”,请使用Hyperlink。这意味着它会触发历史记录更改事件。) 如果您要链接到应用的网站,请使用Anchor

Hyperlink link = new Hyperlink("link to foo", "foo"); //text would be "link to foo", would change your url to yourSite.html#foo
Anchor anchor = new Anchor("Link to bar", "www.bar.com"); //text would be "link to bar", would redirect you to "www.bar.com"