Avatar of srujanmiryala
srujanmiryalaFlag for India

asked on 

Flex Hash Map technique

Dear All,

I have got the code for implementing matrix style for displaying the data(you can see it in the output).

In the inputFlight(Array) the order of the data coming from the XML(which is filtered by finalPricePerPerson) is perfect.

but when it comes to finalFlight(HashMap) for some iterations the order is coming perfect and later the order in the  finalFlight(HashMap) is changing. How to resolve this problem. I need the data in the order of price,
In the final output the order is coming uneven. I need it in the order based on price.

Please someone help me out.
Thankyou.
src.zip
Apache Flex

Avatar of undefined
Last Comment
srujanmiryala
Avatar of dgofman
dgofman
Flag of United States of America image

May I ask first why are you using some third party component HashMap class?

Simple just change your result type in your class from String to Object

internal class _Super_TestClassPort extends com.adobe.fiber.services.wrapper.WebServiceWrapper

//operation.resultElementType = String;
 operation.resultElementType = Object;

You have to get your XML as Object without extra encoding on the client side.
Avatar of srujanmiryala
srujanmiryala
Flag of India image

ASKER

You are right.Thats not a problem actual requirement is that i need to capture all the airline names and the best fare relating to the stops like
if airline name is airindia , i need to capture the zerostop  fare,one stop fare and twostop fare (best fares) and i need to display them as you can see in the matrix style

airindia
0(zero stop fare)
808(one stop fare)
817 (two stop fare)

i have tried to achive this with the array and arraycollections with some hardcode logic and unable to do it.
At last i find this thirdparty hashmap wich can achive this kind of functonality.

but i found that in inputFlight the data is comming in the order but if you can check this code


for each(var item1:Flight in inputFlight){
                      var existFlight:Flight = finalFlight.getValue(item1.getAirline());
                      if(existFlight == null){
                            finalFlight.put(item1.getAirline(),item1);
                            trace("IF Put: "+finalFlight.getKeys());
                  }else{
                            trace("Existing Fligth: "+existFlight.airline);
                            if (item1.getZerostopFare() != 0){
                                  if (existFlight.getZerostopFare() == 0){
                                        existFlight.setZerostopFare(item1.getZerostopFare());
                                  }else if(existFlight.getZerostopFare() > item1.getZerostopFare()){
                                        existFlight.setZerostopFare(item1.getZerostopFare());
                                  }
                            }
                            if (item1.getOnestopFare() != 0){
                                  if (existFlight.getOnestopFare() == 0){
                                        existFlight.setOnestopFare(item1.getOnestopFare());
                                  }else if(existFlight.getOnestopFare() > item1.getOnestopFare()){
                                        existFlight.setOnestopFare(item1.getOnestopFare());
                                  }
                            }
                            if (item1.getTwostopFare() != 0){
                                  if (existFlight.getTwostopFare() == 0){
                                        existFlight.setTwostopFare(item1.getTwostopFare());
                                  }else if(existFlight.getTwostopFare() > item1.getTwostopFare()){
                                        existFlight.setTwostopFare(item1.getTwostopFare());
                                  }
                            }
                            finalFlight.put(existFlight.getAirline(),existFlight);
                            trace("ELSE Put: "+finalFlight.getKeys());
                      }

the data moving into the loop is correct but when the data is pushing into finalflight it is not in the order how the data is pushed.


Avatar of dgofman
dgofman
Flag of United States of America image

I can see you are using Array (not ArrayCollection)
An Array class can represent on Java side as List or HashMap.
If you decalred java.utils.List you should get the same order, but if Hashtable
or Map your order can be changed
ASKER CERTIFIED SOLUTION
Avatar of dgofman
dgofman
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of srujanmiryala
srujanmiryala
Flag of India image

ASKER

Good solution but it cannot help it with my requirements, i have implemented at java side now which is working fine.
Apache Flex
Apache Flex

Apache Flex is a highly productive, open source application framework for building and maintaining expressive web applications that deploy consistently on all major browsers, desktops and devices (including smartphones, tablets and television). It provides a modern, standards-based language and programming model that supports common design patterns suitable for developers from many backgrounds. Flex applications can be deployed to the Adobe Player in the browser, Adobe AIR on desktop and mobile devices or to native Android, iOS, Windows or Mac applications.

4K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo