Here is my java code
public HashMap<Integer, Integer> getNoOfWidgetsFromUsername(final String username) //vikas- method to get pid from db.
{
HashMap<Integer, Integer> obMap = new HashMap<Integer, Integer>();
int numwidgets=getTotalWidgetsOfUser(PartnerID);
obMap.put(new Integer(1),PartnerID);
obMap.put(new Integer(2),numwidgets);
return obMap;
}
I put the above code in a function. I am calling that function from Javascript and returning values to Javascript.
Here is my Javascript code.
JSClientService.getNoOfWidgetsFromUsername(username, {
callback : function(data) {
//here i want to print hashmap values.
}
});
How can I access the data on the Javascript side?
It is a Java object, so you can not access it in javascript (i guess data will be undefined in your case).
Convert your java object to JSON object (something like this)
then in your js callback function ()
code not tested