问题
I have a problem with BlazeDS to Flex mobile deserialization, so that I try to send back list of maps List<Map<String, Object>>
with different Objects in every Map, but when I receive this list in flex code:
hastalarim = event.result as ArrayCollection;
But when I debug this in flex code I see that there're 7 instances of the same Object (the first object that was inserted on server-side) in that list.
Here's my method on server-side:
public List<Map<String, Object>> getHastalarim(String personelId, String servisId) {
List hastalar = karDAO.getHastalarim(personelId,servisId);
Map<String, Object> mp = new HashMap<String, Object>();
List<Map<String, Object>> lst = new ArrayList<Map<String,Object>>();
for (int i = 0; i < hastalar.size(); i++) {
Object[] obj = (Object[]) hastalar.get(i);
mp.clear();
mp.put("hastaId", (String) obj[0]);
mp.put("adi",(String) obj[1]);
mp.put("soyadi", (String) obj[2]);
mp.put("tckimlikNo", (String) obj[3]);
mp.put("yasi", (Integer) obj[4]);
mp.put("vizitTar", obj[5].toString());
mp.put("vizitId", (String) obj[6]);
mp.put("cinsiyeti", (String) obj[7]);
mp.put("resim", getHastaResim((String) obj[3]));
lst.add(mp);
}
return lst;
}
What's the problem here? Any suggestions?
回答1:
for (int i = 0; i < hastalar.size(); i++) {
Object[] obj = (Object[]) hastalar.get(i);
Map<String, Object> mp = new HashMap<String, Object>();
mp.put("hastaId", (String) obj[0]);
mp.put("adi",(String) obj[1]);
mp.put("soyadi", (String) obj[2]);
mp.put("tckimlikNo", (String) obj[3]);
mp.put("yasi", (Integer) obj[4]);
mp.put("vizitTar", obj[5].toString());
mp.put("vizitId", (String) obj[6]);
mp.put("cinsiyeti", (String) obj[7]);
mp.put("resim", getHastaResim((String) obj[3]));
lst.add(mp);
}
return lst;
}
Create multiple instance of map that is causing the issue.
来源:https://stackoverflow.com/questions/10171835/flex-deserialization-issue-with-list-of-maps