Flex deserialization issue with List of Maps

廉价感情. 提交于 2019-12-13 07:26:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!