tags:

views:

46

answers:

2

Hi all!

I didnt found any information even after bunch of searches over internet on how to handle query parameters in GWT application in a nice way. I'm newbie in GWT, but I'm very excited of its potential. So I'm trying to figure out how basic things works here.

The thing I need - the possibility to rewrite query parameters in case of some events. For example user see in the browser: www.some-site.com/conv.html but after some user action I want to change URL to: www.some-site.com/conv.html?convId=XXXXX

How can I do it?

p.s. I think that this is possible throught javascript, which I can make by JSNI. But maybe GWT already have this functionality.

+3  A: 

To get you started, you should read the official documentation about History. It describes the mechanism that allows passing parameters via the url fragment identifier (www.example.com/index.html#test=true) and how it's handled in GWT. The documentation contains examples how to capture and trigger the changes to the url fragment.

You might also be interested with MVP - the Model-View-Presenter pattern that is highly recommended for complex GWT apps. You'll find many questions on SO about it, the official docs also have to parts about it (part 1, part 2). For a quick (ok, the video is hour long, but very informative) introduction you should watch the presentation by Ray Ryan from Google IO 2009 that started the whole MVP + GWT love ;)

Igor Klimer
Thank you for answere and links! It seems that it more complex, as I thought =)
Tornn
It's very important to embrace History as soon as possible in your application - adding it as an afterthought can be a really PITA. But if you do it right (hint: MVP and/or just some good architecture) it will lead to a nice division into modules/states in your application (more or less independent), which in turn can be taken advantage of via code splitting (http://code.google.com/webtoolkit/doc/latest/DevGuideCodeSplitting.html). So IMHO it definitely pays of to use History :)
Igor Klimer
A: 

You can call this function from GWT code:

//redirect the browser to the given url

public static native void redirect(String url) /*-{
          $wnd.location = url;
}-*/;
jgzornoza