In GWT using the History/Activities/Places apis you end up with urls like this
http://192.168.0.104:8888/brokerage.html?gwt.codesvr=192.168.0.104:9997#StartPlace:params
Where the word params is the place "token" where parameters can be passed into the StartPlace object. For most of my applications a single string is enough to reload my data with refreshed is pressed. On a few Activities/Places/Pages however I need to split that Place token into a number of name/value pairs.
Does anybody have a suggestion for how to handle this? I am currently writing a class that builds a string out of name/value pairs by separating them in a url fashion using &name=value. It would be great if somebody knew of a class that could handle this or something.
String parameters="name1=value1&name2=value2&name3=value3";
HashMap<String, String> parameterMap = new HashMap<String, String>();
String[] parameterPairs = parameters.split("&");
for (int i = 0; i < parameterPairs.length; i++) {
String[] nameAndValue = parameterPairs[i].split("=");
parameterMap.put(nameAndValue[0], nameAndValue[1]);
}
....
String name1Value = parameterMap.get("name1");
This is all untested code, and it has unchecked array bounds! Make sure you don't have extraneous '&' or '=' signs, since they'll mess up the parsing.