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.
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).
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.
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