Reputation: 90023
HTML file:
<a id="search">Search</a>
GWT Module:
Anchor searchLink = new Anchor("Search", Window.Location.createUrlBuilder().setPath("search.html").buildString());
RootPanel.get("search").add(searchLink);
Results in:
<a id="search">Search
<a class="gwt-Anchor" href="http://127.0.0.1:8888/search.html?gwt.codesvr=127.0.0.1:9997">Search</a>
</a>
Is there a way for me to edit the existing anchor (replacing its body) instead of inserting inside it?
Upvotes: 1
Views: 710
Reputation: 6025
Use Document#getElementById()
to get the existing anchor Element instead of RootPanel#get()
:
Anchor searchLink = Anchor.wrap(Document.get().getElementById("search"));
searchLink.setHref(Window.Location.createUrlBuilder().
setPath("search.html").buildString());
Upvotes: 1
Reputation: 601
The correct use of GWT Document class is:
Document.get().getElementById("search")
Upvotes: 1