1 Reply Latest reply on Oct 14, 2010 7:44 PM by manpakhong

    java.util.Map to flash.utils.Dictionary

    ezfira Level 1

      Hi,

      I'm using Blazeds for my remoting between Flex and Java. I have an Object-to-object map on the Java side. This converts to an untyped Object in Flex having the properties as the 'toString' of the key Object.

       

      Has anyone been able to convert an Object-to-object java map to a flash Dictionary object? Why wouldn't it do that as default?

       

      Thanks,

      Eyal

        • 1. Re: java.util.Map to flash.utils.Dictionary
          manpakhong

          Yes, You can, I have successfully mapping form java HashMap to Flex Dictionary. The following is the code fragment for the success case:

          The hint is that you need to use ObjectProxy in Flex to map HashMap in Java.

           

          Man Pak Hong, Dave

           

          Analyst Programmer

           

          manpakhong@hotmail.com

          manpakhong

           

          Java:

          // ================================================================================

              public Map<String, Object> getCaseDetails(Long sid) throws ApplicationException, SystemException {
                 
                  // Vos Declaration
                  Case caseVo = null;
                  UserInfo ossUserInfoVo = null;
                  UserInfo spUserInfoVo = null;
                  Ngo ossNgoVo = null;
                  Ngo spNgoVo = null;
                  Personal personalVo = null;
                  Contact contactVo = null;
                  CaseAttachment caseAtthVo = null;
                  Office ossOffice = null;
                  SwdOffice swdOffice = null;
                  UserInfo swdEao = null;
                  NeedAssess needAssess = null;
                  List <CaseRegPropVw> caseRegPropVwList = null;       
                 
                 
                 
                  CaseDao daoCase = new CaseDao();       
                  caseVo = daoCase.getCase(sid);
                 
                  if (caseVo != null)
                  {
                      UserInfoDao daoUserInfo = new UserInfoDao();
                      ossUserInfoVo = daoUserInfo.getUserInfo(caseVo.getOssCmSid());
                      spUserInfoVo = daoUserInfo.getUserInfo(caseVo.getNgoCmSid());
                     
                      // caseRegProp
                      CaseRegPropVwDao daoCaseRegPropVw = new CaseRegPropVwDao();

           

                      caseRegPropVwList = daoCaseRegPropVw.listCaseRegPropVwByLessRegNo(caseVo.getLessRegNo());           
                     
                  }

           

                  NgoDao daoNgo = new NgoDao();
                 
                  if (ossUserInfoVo != null)
                  {
                      ossNgoVo = daoNgo.getNgo(ossUserInfoVo.getNgoSid());
                  }
                 
                  if (spUserInfoVo != null)
                  {
                      spNgoVo = daoNgo.getNgo(spUserInfoVo.getNgoSid());
                  }
                 
                 
                 
                  // personal
                  if (caseVo != null)
                  {
                      PersonalDao daoPersonal = new PersonalDao();
                      personalVo = daoPersonal.getPersonal(caseVo.getPersonalSid());
                     
                      // jscontact
                      ContactDao daoContact = new ContactDao();
                      contactVo = daoContact.getContact(caseVo.getSid());
                     
                      // ossCaseAtth
                      CaseAttachmentDao daoCaseAtth = new CaseAttachmentDao();
                      caseAtthVo = daoCaseAtth.getCaseAttachment(caseVo.getSid(), CaseAttachmentPolicy.ATT_TYPE_CONSENT_FORM);
                     
                      // ossOffice
                      OfficeDao daoOssOffice = new OfficeDao();
                      ossOffice = daoOssOffice.getOffice(caseVo.getOssOfficeSid());
                  }

           


                 
                 
                  if (personalVo != null)
                  {
                      // swdOffice
                      SwdOfficeDao daoSwdOffice = new SwdOfficeDao();
                      swdOffice = daoSwdOffice.getSwdOffice(personalVo.getSwdOfficeSid());
                     
                      // swdEao
                      UserInfoDao daoSwdEao = new UserInfoDao();
                      swdEao = daoSwdEao.getUserInfo(personalVo.getSwdEaoSid());
                     
                      // needAssess
                      NeedAssessDao daoNeedAssess = new NeedAssessDao();
                      needAssess = daoNeedAssess.getNeedAssess(personalVo.getSid());

           

                  }
                 
                  Map<String, Object> hm = new HashMap<String, Object>();
                  hm.put("Case", caseVo);
                  hm.put("OssUserInfo", ossUserInfoVo);
                  hm.put("NgoUserInfo", spUserInfoVo);
                  hm.put("OssNgo", ossNgoVo);
                  hm.put("SpNgo", spNgoVo);
                  hm.put("Personal", personalVo);
                  hm.put("Contact", contactVo);
                  hm.put("CaseAtth", caseAtthVo);
                  hm.put("OssOffice", ossOffice);
                  hm.put("SwdOffice", swdOffice);
                  hm.put("SwdEao", swdEao);
                  hm.put("NeedAssess", needAssess);
                  hm.put("CaseRegPropsVw", caseRegPropVwList);
                     
                 
                 
                 
                  return hm;
              }

           

          Flex part

          // ==================================================================================

                      // CASEDETAILS
                      private function getCaseDetailsResultHandler(result:ObjectProxy):void
                      {
                          var dc:ObjectProxy = result;
                         
                          this.editItemOssUserInfo = dc["OssUserInfo"];
                          detailCaseInfo.editItemOssUserInfo = editItemOssUserInfo;
                         
                         
                          this.editItemOssNgo = dc["OssNgo"];
                          detailCaseInfo.editItemOssNgo = editItemOssNgo;   
                         
                          this.editItemCase = dc["Case"];       
                          detailCaseInfo.editItemCase = editItemCase;
                          detailPersonalInfo.editItemCase = editItemCase;   
                         
                          this.editItemPersonal = dc["Personal"];
                          detailCaseInfo.editItemPersonal = editItemPersonal;
                          detailPersonalInfo.editItemPersonal = editItemPersonal;
                         
                          this.editItemContact = dc["Contact"];
                          detailCaseInfo.editItemContact = editItemContact;
                          detailPersonalInfo.editItemContact = editItemContact;
                         
                          this.editItemCaseAtth = dc["CaseAtth"];
                          detailCaseInfo.editItemCaseAtth = editItemCaseAtth;
                         
                          this.editItemOssOffice = dc["OssOffice"];
                          detailCaseInfo.editItemOssOffice = editItemOssOffice;
                         
                          this.editItemSwdOffice = dc["SwdOffice"];
                          detailCaseInfo.editItemSwdOffice = editItemSwdOffice;
                         
                          this.editItemSwdEao = dc["SwdEao"];
                          detailCaseInfo.editItemSwdEao = editItemSwdEao;
                         
                          this.editItemNeedAssess = dc["NeedAssess"];
                          detailCaseInfo.editItemNeedAssess = editItemNeedAssess;
                         
                          this.listItemCaseRegPropVw = dc["CaseRegPropsVw"];
                         
                         
                         
                          this.caseDict = new Dictionary();               
                          caseDict[CaseDetailPolicy.INIT_OSSUSERINFO] = editItemOssUserInfo;
                          caseDict[CaseDetailPolicy.INIT_OSSNGO] = editItemOssNgo;
                          caseDict[CaseDetailPolicy.INIT_CASE] = editItemCase;
                          caseDict[CaseDetailPolicy.INIT_PERSONAL] = editItemPersonal;
                          caseDict[CaseDetailPolicy.INIT_CONTACT] = editItemContact;
                          caseDict[CaseDetailPolicy.INIT_CASEATTH] = editItemCaseAtth;
                          caseDict[CaseDetailPolicy.INIT_OSSOFFICE] = editItemOssOffice;
                          caseDict[CaseDetailPolicy.INIT_SWDEAO] = editItemSwdEao;
                          caseDict[CaseDetailPolicy.INIT_NEEDASSESS] = editItemNeedAssess;               
                         
                          // detailCaseInfo.init();
                      }