how to get full URL inside init()?


Is there a way to get the full URL the user requested from inside Application.init()?

I have a Vaadin app (a form) mapped to /request/* in web.xml, and I can view the (blank) form by going to http://localhost:8080/request.

I’d like to fill up the form based on the data after “/request/”, eg. if record “1234” already exists, then http://localhost:8080/request/1234 should open a form filled with data from record “1234”.

I’ve tried getting the URL using app.getMainWindow().getURL(), but it always returns “http://localhost:8080/request/1/” irrespective of what I put after the “/request/” part of the URL.

So, how do we get the full requested URL from inside Application.init()? Or, is there a better way to achieve what I want?

thanks alot, cheers.

Window.getURL() returns the URL you could use to open a window from the application, not the actual parameters the user gave.

Achieving what you want in Application.init() this is a bit tricky, but usually registering a URIHandler for your window and doing the relevant initialization for the window, not the application, should let you do what you want. With a HttpServletRequestListener, it would also be possible (although a little “hacky”) to make the URL available also to Application.init().

Using URI fragments (anchors, with “#”) with UriFragmentHandler would be another option that lets your application avoid some page reloads when changing pages.

Vaadin 7 will probably simplify these.

Thanks Henri.

I stumbled upon the URIHandler method as well while going through the APIs, and it seems adequate for what I need, so I’ll use that for now.

thanks again, cheers.