In a GWT 2.1+ app, how can I generate a link to a place for external consumption?
For instance, say I want to create a link to Place1. For internal consumption I could do presenter.goTo(new Place1("token"))
. How can I make this into an Anchor
or some sort of link that users can paste into their browser?
Here's how I would do:
final Place1 place = new Place1("token");
Anchor anchor = new Anchor("go to place 1", "#" + placeHistoryMapper.getToken(place));
anchor.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
placeController.goTo(place);
event.preventDefault();
}
});
As far as I know as i am new to GWT myself, if you use Hyperlink instead of Anchor you will not have to write the event handler. It will redirect you to the place and handle the history stuff automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With