This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Flex and the fly likes Extracting values from an ArrayList into String variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Flex
Bookmark "Extracting values from an ArrayList into String variables" Watch "Extracting values from an ArrayList into String variables" New topic
Author

Extracting values from an ArrayList into String variables

Nitin Menon
Ranch Hand

Joined: Jun 13, 2007
Posts: 79
Hi,
I have an issue in my application.
I get a list of objects from a java class into an ArrayCollection variable in my action script page. The ArrayList consists of key value pairs which is used to display in a combo box. when one of the value is selected, i need to get the value into a String variable. Only then can I go for further processings and use the resultant string variable to fetch values from DB.
So, can anyone help me how to get the values from an arrayList into a String Variable.

thanks in advance...!
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

An ArrayList of key value pairs? Do you mean this? Lists don't have keys, though they do have indices that are kind of like keys.

ArrayCollections can be keyed on a string value, but you presumably have int values in there if you created it from an ArrayList. Typically in Flex you just pass your data to the control as is and Flex will do the rest. Can we see the code you've tried?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Nitin Menon
Ranch Hand

Joined: Jun 13, 2007
Posts: 79
Ooh..! I am sorry.
I just found out that that they were not key value pairs. It was in the format (Example) : [{"IND,India"},{"UK,United Kingdom"}, {"US,United States"}] and so on. The database had values stored in the
above format. These are displayed in a combo box.
Suppose I select one of them, i want it in a String variable. only then can i call a Java method which takes a string variable as its parameter.
Narender Reddy Soma
Greenhorn

Joined: Jun 05, 2010
Posts: 23
Nitin Menon wrote:Ooh..! I am sorry.
I just found out that that they were not key value pairs. It was in the format (Example) : [{"IND,India"},{"UK,United Kingdom"}, {"US,United States"}] and so on. The database had values stored in the
above format. These are displayed in a combo box.
Suppose I select one of them, i want it in a String variable. only then can i call a Java method which takes a string variable as its parameter.


If you get associated ArrayCollection , and you want to get value as String. You have String Var in Flex ,what is the problem? You can happyly pass that into RemoteObject call . Did'nt I understood the issue correctly?

Nitin Menon
Ranch Hand

Joined: Jun 13, 2007
Posts: 79
Narender Reddy Soma wrote:
If you get associated ArrayCollection , and you want to get value as String. You have String Var in Flex ,what is the problem? You can happyly pass that into RemoteObject call . Did'nt I understood the issue correctly?


But, my arrayCollection here receives a list of objects from a Java class..! ('')
Narender Reddy Soma
Greenhorn

Joined: Jun 05, 2010
Posts: 23
Nitin Menon wrote:
Narender Reddy Soma wrote:
If you get associated ArrayCollection , and you want to get value as String. You have String Var in Flex ,what is the problem? You can happyly pass that into RemoteObject call . Did'nt I understood the issue correctly?


But, my arrayCollection here receives a list of objects from a Java class..! ('')


Ok, Let me put like this . Say for e.g, you are getting CustomerObject from server as result of call on remoteobject

Now, I hope you have a equivalent CustomerObject.as file with [RemoteClass(alias="blah.blah.CustomerObject")] for mapping javaobject to your .as object. Correct me if I am wrong?

Nitin Menon
Ranch Hand

Joined: Jun 13, 2007
Posts: 79
Narender Reddy Soma wrote:
If you get associated ArrayCollection , and you want to get value as String. You have String Var in Flex ,what is the problem? You can happyly pass that into RemoteObject call . Did'nt I understood the issue correctly?

Yeah..! Thats also my scenario..! Also, i have a java method i've declared in my remote object tag in the mxml file. on result, i get a list of objects into an ArrayCollection variable. This arraycollection variable is supposed to be the data provider of the combo box.
 
jQuery in Action, 2nd edition
 
subject: Extracting values from an ArrayList into String variables
 
Similar Threads
Incompatible Types
Problem with passing variables between methods and classes (I think)
Extracting values from an ArrayList?
How to access to an ArrayList from the JSP
How to Get the check box in html:checkbox automatically get checked on display .