views:

1018

answers:

2

I want to support linking with url request parameters in my GWT app. Example

http://host/app?action=A&p1=v1&p2=v2

I am able to process the action=A & other params, but once I am done with that, I want to change the URL to remove them.

The problem is that once the user comes to the webpage, for completing the "action" with parameters p1 & p2, he may browse the site, and come back to the same page for the same "action" but with different value for parameters p1, p2. The second time around though, I dont really want to process the old values for p1 & p2.

I checked Window.Location.replace() but it reloads the page, and all application state is lost.

Is there a way to do this without reloading the page entirely without the params? Perhaps by "removing" the query params?

Any other more sensible way to achieve this?

+2  A: 

Have you tried the History class? You could listen for the ValueChangeEvents, parse the parameters there (the format of the url would change a bit but that shouldn't be an issue) and after that you can "clean" the url of the current page with History.newItem("something/maybeNull") or History.newItem("something/maybeNull", false) if you want to prevent the ValueChangeEvent event from firing.

Igor Klimer
A: 

History per Igro's suggestion is the way to go if you can. If you HAVE to process information on the sever before you can even show somebody the page that is going to host the GWT, then you can process them w/ the servlet or whatever server-side technology you are using and send a 304 to redirect the user to a page that doesn't have the get Params in the URL. Also you could potentially use POST instead of GET, but that's kind of ugly too (Depending on what exactly you're doing). Definitely try to use the History system if possible.

Steve g