Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT Anchor to Place?

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?

like image 200
Justin Avatar asked Mar 08 '11 06:03

Justin


2 Answers

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();
  }
});
like image 116
Thomas Broyer Avatar answered Oct 22 '22 03:10

Thomas Broyer


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.

like image 2
M.Sameer Avatar answered Oct 22 '22 01:10

M.Sameer