I have to created a dynamic URLcontaining the user id and email parameters, which will direct to sign up form in my GWT application. I want to set and get the parameters in the query string. I have referred tp http://code.google.com/p/gwt-examples/source/browse/trunk/System/src/com/gawkat/gwt/system/client/global/QueryString.java?r=1241 but here QueryStringData is inaccessible to my project.Please tell me how I can do it? Any alternative could also help me.
The QueryString collection is a parsed version of the QUERY_STRING variable in the ServerVariables collection. It enables you to retrieve the QUERY_STRING variable by name. The value of Request. QueryString(parameter) is an array of all of the values of parameter that occur in QUERY_STRING.
A query string is a set of characters tacked onto the end of a URL. The query string begins after the question mark (?) and can include one or more parameters. Each parameter is represented by a unique key-value pair or a set of two linked data items. An equals sign (=) separates each key and value.
Query strings are often called parameters because they are used to pass parameters to code that runs on a landing page. Learn more about passing parameters to keyword landing pages from keyword landing page URLs in Search Ads 360.
The "query string" is defined as a question mark followed by the parameters and their values. Each parameter is listed one after the other in the query string, separated by an ampersand (&). It makes no difference what order the query string parameters are in.
@Stein, but there is (a query parameter tokenizer in GWT): e.g. Window.Location.getParameter("debug")
will return the string value of the parameter debug
.
Don't think there's a simple tokenized query string parser in GWT. But you can get the raw query string by using:
String queryString = Window.Location.getQueryString();
Parse it any way you like. I use it like this to set debug flags etc.:
boolean debugMode = Window.Location.getQueryString().indexOf("debug=true") >= 0;
Note that changing values in the query part of the url (between the ?
and the #
) will reload the page. While changing the "hash part" of the url (anything after the #
) will not reload the page. Which is why the com.google.gwt.user.client.History uses the hash part.
If you want really want to parse the history token (hash part) to encode parameters, here's the code for that:
private static Map<String, String> buildHashParameterMap() {
final String historyToken = History.getToken();
Map<String, String> paramMap = new HashMap<String, String>();
if (historyToken != null && historyToken.length() > 1) {
for (String kvPair : historyToken.split("&")) {
String[] kv = kvPair.split("=", 2);
if (kv.length > 1) {
paramMap.put(kv[0], URL.decodeQueryString(kv[1]));
} else {
paramMap.put(kv[0], "");
}
}
}
return paramMap;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With