tags:

views:

30

answers:

2

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)

+1  A: 

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.

Jason Hall
+1  A: 

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();
    }
});
Igor Klimer
This is a very good suggestion. A full MVP framework may be too much for your needs, at this point anyway. Using this simpler approach will get the job done, but you may want to at least investigate MVP and gwt-presenter too, depending on your application's complexity.
Jason Hall