I think I'm running into an error that appears strange. The code below is in a Callback. I'm receiving a JSON from server and need to interrogate it. Here's the client side code segment in onReponseReceived(...)
I'm using java.util.HashMap.
-- ...
String json = response.getText();
SearchResponseJson responseJson = SearchResponseJson.build(json);
String primaryMoleculeId = responseJson.gerPrimaryMatchingId();
if (primaryMoleculeId != null) {
String tId = molecule.gettId() + "";
HashMap<String, String> idMap = responseJson.getIdMap();
String id = idMap.get(tId); // <-- affending line
molecule.setId(id);
}
...The line String id = idMap.get(tId) throws an exception with the message "Exception name: JavaScriptException(TypeError) : idMap_0_g$.get_107_g$ is not a function?. Strangely if String tId = molecule.gettId() + "" line is changed to this - Integer tId = molecule.gettId() it still compiles (I expected String id = idMap.get(tId) to fail, having the key declared Integer in the map). Both lines compile but neither works. In super dev debug mode the content of the map entry I'm trying to get appears as 894830631:"AVaFi4md0u8eNTTDvmDv". Please notice the lack of quotes around the number; that's how it appeared.
Method responseJson.gerPrimaryMatchingId(); is implemented as -
public final native HashMap<String, String> getIdMap() /*-{
return this.idMap;
}-*/;And the JSON is
{
"primaryMatchingId":"AVaFi4md0u8eNTTDvmDv",
"idMap":{
"894830631":"AVaFi4md0u8eNTTDvmDv" // <-- notice the quotes around the key
},
"identicalMatchingIds":[
],
"matchingIds":[
"AVaFi4md0u8eNTTDvmDv"
],
"messageMap":{
},
"statusMap":{
"894830631":1
}
}I'm using java.util.HashMap.
Any help would be greatly appreciated.
Velu
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment