3

I am trying to pass a string of data which is a hashmap from a javascript to a java function by making an Ajax DWR call as below:

var str11 = {
             "78965":{"age":"34yrs","height":"4"},
             "44589":{"age": "32yrs", "height": "99yrs"}
            };

person= 233453;

Person.saveSelected(planOid,
                    str11,
                    {
                     callback:savedValues,
                     errorHandler:handleError
                    }
                   );

But at the other end in my Java class i.e PersonService.java, I receive both of the params successfully but when I examine the hashmap it takes the form as below:

{
 44589={age:reference:c0-e5, height:reference:c0-e6}, 
 78965={age:reference:c0-e2, height:reference:c0-e3}
}   

I am not able to understand why the the references. Instead I am expecting a proper hashMap . Can any one sort out what the problem is with DWR marshaling behind the scenes?

Doug Porter
  • 7,721
  • 4
  • 40
  • 55
deepak
  • 31
  • 4
  • Could you post the Java code for your Java object that you are placing in the hashmap (the one with age and height)? – Doug Porter Feb 17 '11 at 20:18

1 Answers1

0

Map<String, Object> is not specific enough for DWR to know which object to instantiate. So you will have to use Map<String, YourConcreteClass> (a collection in you case).

This means that you cannot use different types for values in your map (which shouldn't be problem in your case).

Martin Lazar
  • 1,330
  • 16
  • 24