subh
subh

Reputation: 21

How to provide hyperlink in email pointing to a specific method inside gwt app (but not main page)

My GWT app has a search result with orderid column as hyperlink. On clicking, it opens up another tab which shows the details.

I want to expose this particular functionality externally say in an email

http://www.myapp.com/XYZApp.html?orderid=1234

so that user can directly go to the details page after login to the App. In JSP world, it was pretty straightforward.

Is it possible in GWT given that the call to show up the details page is not in the main GWT module (XYZApp.html)

Upvotes: 2

Views: 219

Answers (2)

Igor Klimer
Igor Klimer

Reputation: 15321

While I agree with Jason that MVP (which gwt-presenter is an implementation of, sort of ;)) and GWT go well together, I'm not a big fan of gwt-presenter (complicates stuff too much, IMHO). So in case you want to roll out your own "framework" for MVP or just don't want to use MVP (switching to MVP can be a PITA, especially if the project is big/complex), you can just use the History class, that comes with GWT:

History.addValueChangeHandler(new ValueChangeHandler<String>() {
    @Override
    public void onValueChange(ValueChangeEvent<String> event) {
        String url = event.getValue();
    }
});

Upvotes: 1

Jason Hall
Jason Hall

Reputation: 20920

An analog to URL-parameter-defined state in GWT is Places, provided by the gwt-presenter project.

Instead of being a URL parameter like ?orderId=1234, you could link to myapp.com#id=1234;

Going to this URL would trigger a PlaceRequestEvent which you could subscribe to using the EventBus*.

eventBus.addHandler(PlaceRequestEvent.getType(), new PlaceRequestHandler() {
  @Override
  void onPlaceRequest(PlaceRequestEvent event) {
    String id = event.getRequest().getParameter("id", "");
    // show the item with this ID...
  }
});

*The EventBus is awesome, and you should be using it (or something like it) whether or not you decide to use Places.

Upvotes: 1

Related Questions