Getting parameters from URL

149 views
Skip to first unread message

Ayzen

unread,
Aug 7, 2006, 1:47:51 PM8/7/06
to Google Web Toolkit
Hi.

I need to have in my GWT app a possibility to get parameters from URL.
For example in http://site.com/gwtapp.html?name=Test I need to get the
parameter name. In JavaScript I use location.search, so I wrote native
method which returns this. But it doesn't work. I looked at compiled
sources and did some changes:
In nocache.html(selectScript() function) I changed
location.replace(strongName + '.cache.html')
to
location.replace(strongName + '.cache.html' + location.search).
In gwt.js (__gwt_injectWebModeFrame(name) function) I changed
var selectorURL = parts[0] + parts[1] + ".nocache.html"
to
var selectorURL = parts[0] + parts[1] + ".nocache.html" +
location.search.

After these changes all works fine, but I don't think this solution is
good. Is there more easier way to do that? Maybe I missed something?

Sorry for my English.

Thanks.

jdc

unread,
Aug 7, 2006, 3:58:46 PM8/7/06
to Google Web Toolkit
for your native method, return
$wnd.location.search

see Robert Hanson's org.gwtwidgets.client.util.WindowUtils.java for
more location methods,
and remember to hang things off of $wnd rather than window (dunno why,
but it's what works best).

Ayzen

unread,
Aug 7, 2006, 5:08:38 PM8/7/06
to Google Web Toolkit
Thanks a lot.

I think '$wnd' is a link to main browser's window object and 'window'
is belong to IFRAME which is creating by gwt.js in
__gwt_injectWebModeFrame function.

IamRobe...@gmail.com

unread,
Aug 7, 2006, 8:29:28 PM8/7/06
to Google Web Toolkit
Distribution and source URL for the WindowUtil class that JDC
mentioned:

http://gwt-widget.sourceforge.net
http://gwt-widget.sourceforge.net/docs/xref/org/gwtwidgets/client/util/WindowUtils.html

Sample usage:

Location loc = WindowUtils.getLocation();
String val = loc.getParameter("name");

Rob

Reply all
Reply to author
Forward
0 new messages