How to convert an array collection instance to a complex object for interaction with webservice

Hi there,
I have a stubborn problem that I am trying to work out the best way to solve the problem.  I am interacting with a WebService via HTTPService calling a method called find(String name) and this returns me a List of ComplexObjects that contain general string and int params and also lists of other Complex Objects.  Now using the code:
ArrayCollection newOriginalResultsArray = new ArrayCollection(event.result as Array)
flex converts my complex objects results to an arraycollection so that I can use it in datagrids etc.  Now up until this part is all good.  My problem is when getting a single instance from the results list, updating it by moving data around in a new datagrid for example - I want to interact with the webservice again to do an create/update.  This is where I am having problems - because these webservice methods require the complex object as a parameter - I am struggling to understand how I can convert the array collection instance back to my complex object without iterating over it and casting it back (maybe this is the only way - but I am hoping not).
I am hoping that there is a simple solution that I am missing and that there is some smart cookie out there that could provide me with an answer - or at least somewhere to start looking. I guess if I have no other alternative - maybe I need to get the people who built the service to change it to accept an array - and let them do the conversion.
Any help would be greatly appreciated.
Bert

Hi Bert,
According to my knowledge you can use describeType(Object) method which will return an XML... That XML will contain Properties and values just iterate through the XML and create a new Object..   Probably u can use this method...
public function getObject(reqObj:Object,obj:Object,instanceName:String,name:String=null,index:int=-1):Obj ect
            if(!reqObj)
                reqObj = new Object();
            var classInfo:XML = describeType(obj);
            var className:String = instanceName;
            if(name!=null)
                className=name+"."+className;
            if(index!=-1)
                className=className+"["+index+"]";
            for each (var v:XML in classInfo..accessor)
                var attributeName:String=v.@name;
                var value:* = obj[attributeName]
                var type:String = v.@type;
                if(!value)
                    reqObj[className+"."+attributeName] = value; 
                else if(type == "mx.collections::ArrayCollection")
                    for(var i:int=0;i<value.length;i++)
                        var temp:Object=value.getItemAt(i);
                        getReqObject(reqObj,temp,attributeName,className,i);
                else if(type == "String" || type == "Number" || type == "int" || type == "Boolean")
                    reqObj[ className+"."+attributeName] = value; 
                else if (type == "Object")
                    for (var p:String in value)
                        reqObj[ className+"."+attributeName+"."+p] = value[p];
                else
                    getReqObject(reqObj,value,attributeName,className);
            return reqObj;
Thanks,
Pradeep

Similar Messages

  • How to convert 1D array of string to string

    How to convert 1D array of string to string.

    Maximus00, as Pavel indicated, there is a lesser known feature of "Concatenate Strings" that does exactly what your code is doing if the input is an array of strings. In one step! See attached image.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ConcatenateArray ofStrings.gif ‏7 KB

  • How to convert from array to graph ?

    how to convert from array to graph ?

    A graph will accept an array of numbers.  Do you have an example of what you are looking for?
    And since somebody mentioned tutorials...
    3 Hour Introduction
    6 Hour Introduction
    LabVEW Basics
    Self Paced training for students
    Self Paced training beginner to advanced, SSP Required
    LabVIEW Wiki on Training
    Learning NI
    Getting Started with NI Products
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to convert an array of numbers into a time signal?

    I have an array of 512 data points. I want to convert this array into a time domain signal (the one with the brown color). How would I do this? Please let me know soon...Thanks!

    If you are referring to waveform data type, use the "build waveform" function as illustrated in the attached vi. Also check LabVIEW help waveform example for more sample vi.
    Attachments:
    sample_vi.vi ‏30 KB

  • How to convert an excel file where customers have partial access for selecting items.

    Please Advise,
    I have created an excel file with columns that calculates price and quantity. I need to know how my customers can access the file without seeing all my calculations, etc. and just select the number of items. I need to keep my excel formula info confidential and at the same time having the customers the ability to select the items.
    This excel file will be placed on my web site and linked where customers have access to it. They make their selections and emailed back for processing.with their selected items. If the excel file is converted into a pdf file, Then placed and linked for customer access how can customers have partial access and select in certain columns and have excel fuction for calculations?
    Thanks,
    Dan

    [discussion moved to Creating, Editing & Exporting PDFs forum]

  • How to convert the output of Applescript which is in object format to text or string format??

    Hi All,
    I want to convert the output of Applescript which is in object format to string or text format, am running Applescript with Java, I need to display the output of applescript in Eclipse Java Console, since its object format the output is not properly displayed..
    Pls suggest.. I used the below code
    repeat with i in allContents
                if class of i is button then set the end of allStaticText to contents of i
            end repeat
    Applscript ouptput
    {button 1 of window "Player Installer" of application process "Install  Player" of application "System Events", button 2 of window "Player Installer" of application process "Install  Player" of application "System Events", button 3 of window "Player Installer" of application process "Install  Player" of application "System Events", button "Finish" of UI element 1 of scroll area 1 of window "Player Installer" of application process "Install  Player" of application "System Events"}
    Java output
    <NSAppleEventDescriptor: 'obj '{ 'form':'indx', 'want':'butT', 'seld':1, 'from':'obj '{ 'form':'name', 'want':'cwin', 'seld':'utxt'(" Player Installer"), 'from':'obj '{ 'form':'name', 'want':'pcap', 'seld':'utxt'("Install  Player"), 'from':'null'() } } }>

    Here's an improved version of the previous script, where the handler now returns "button 2 of window \"Untitled\" of application process \"TextEdit\" of application \"System Events\"" instead of "button \"2\" of window \"Untitled\" of application process \"TextEdit\" of application \"System Events\"":
    tell application "System Events"
        get button 2 of window 1 of process "TextEdit"
        my objectToText(result) --> "button 2 of window \"Untitled\" of application process \"TextEdit\" of application \"System Events\""
    end tell
    on objectToText(UI_element)
        set theText to ""
        tell application "System Events"
            repeat
                if exists attribute "AXParent" of UI_element then
                    set theParent to value of attribute "AXParent" of UI_element
                    set theClass to class of UI_element
                    if name of UI_element exists then
                        set theName to name of UI_element
                        set theText to theText & (theClass as text) & " \"" & theName & "\" of "
                    else
                        set k to 0
                        get UI elements of theParent whose class is theClass
                        repeat with thisItem in result
                            set k to k + 1
                            if contents of thisItem is UI_element then exit repeat
                        end repeat
                        set theIndex to k
                        set theText to theText & (theClass as text) & " " & theIndex & " of "
                    end if
                    set UI_element to theParent
                else
                    set theClass to class of UI_element
                    set theName to name of UI_element
                    set theText to theText & (theClass as text) & " \"" & theName & "\" of application \"System Events\""
                    exit repeat
                end if
            end repeat
        end tell
        return theText
    end objectToText
    Message was edited by: Pierre L.

  • How to convert digital array data into analog signal

    i want help to convert digital data array into analog signal

    shubham62 wrote:
    We are implimenting real time audio trans-receiver. We have converted input audio data(analog form) into digital data. At the receiver side we received digital data which is in the form of digital data array.But we are unable to recover back our original input data. So please help us to sort out the problem.
    Still no useful information.  How was the data converted to digital in the first place?  What conversion parameters did you use?  As was said, you just need to do the math backwards to get it back into the analog.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to convert an array of bits into an array of bytes?

    If I have an array of 1s and 0s, how can I pack them
    into an array of bytes (8 bits)?
    Thanks.

    NI recommends to get rid of 4.x mode (Quote from the help file: "National Instruments recommends reworking any application that uses the Convert 4.x Data mode as a long term solution."). For this reason, I have attached an alternative example to give you some ideas.
    (The previous example (using 4.x type cast) is actually slightly flawed, because for some reason it only produces even sized output arrays (why???) so you would need to trim the resulting array as a function of the input array size.)
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    OnesAndZeroesU8v2.vi ‏43 KB

  • How to convert an array of Integers into String

    So how can an array of integers be converted into a string?
    As I do not have a javac with me now, I hope you guys could help.
    Can it be done this way:
    int [] value = new int[] {2,3,4,5,6,7}
    String strValue = "";
    for (i=0; i<value.length-1; i++)
    strValue += value;

    Instead of working with Strings, I would suggest you use a StringBuffer. It will improve memory utilization.
    Like this:
    int [] values = new int[] {2,3,4,5,6,7};
    StringBuffer sbTmp = new StringBuffer();
    final int size = values.length;
    for (i = 0; i < size; i++) {
    String intStr = Integer.toString(values);
    sbTmp.append(intStr);
    String strValues = sbTmp.toString();

  • How to convert an array having ramp pattern to ..................

    i used an ramp generator to obtain numbers. the output is an array
    having ramp pattern. how do i convert it to a set of numbers?
    thank you,
    siva.

    Hi Siva,
    Take a look at the example that can be found at
    Help >>> Search Examples >>> Browse >>>Hardware Input and Output >>> DAQ >>> Analog Output >>> Continuous Generation.VI.
    You are not going to be able to get better than 1KHz out of your digital output line becuase Windows was never designed to be able to let you cycle that fast. It was designed to to 30Hz, just fast enough to make it look like it is smooth.
    The example I cited should let you "crank-up" your output speed. You will probably have to modify it to get a square wave but, that is just data.
    Trying to help,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to convert String array into int.

    void getSoldSms(Vector vecSoldSms)
         String str[]=new String[vecSoldSms.size()];
         String words[]=new String[str.length]; // String array
              for(int i=0;i< vecSoldSms.size();i++)
                   str=(String)vecSoldSms.get(i);
              }               //End for
              for(int i=0;i<str.length;i++)
              words = str[i].split("\\|\\|");
              System.out.println();
              for(int j=0;j<1;j++)     
              int count[str.length]=Integer.parseInt(words[i]);
              System.out.print(count[j]*advance_count);
              } // end inner for loop
              }          //End for
         }          //End function getSoldSms
    how do i convert words which is a string array into int type. i kno string can be converted into int using interger.parseint. but wat abt string arrays??? plz help me out with the above code.

    i did tht its still giving the same errorFor Heaven's sake, what about taking a second to try to understand the code you're copying first? If you really can't fix the error yourself, you have a more serious problem than just convertingStrings to ints.
    And if you want { "1", "2", "3" } to be 123:
    StringBuffer b = new StringBuffer();
    for (int i = 0; i < array.length; i++) {
      b.append(array);
    int result = Integer.parseIn(b.toString());

  • How to convert char array to string

    sirs,
    i have written a method in java which will return a randomly generated string of a fixed length. i am creating one one character and inserting it into char array.
    at last i am converting it to string
    like this
    String newpass= pass.toString();// pass is a char array
    but problem is that the string is having different value what i hav generated.
    if i am doing like this..
    String newpass= new String(pass);// pass is a char array
    here newpass is having correct value but having some error
    error in the sense when i print
    System.out.println(newpass+"some text");
    "some text" is not printing
    can you suggest the better way

    /*this is my method */
    private String generateString(int len){
              char pass[] = new char[10];
              int cnt=0;
              int temp=0;
              Random randomGenerator = new Random();
                   for (int idx = 0; idx < 1000; ++idx)
                        temp = randomGenerator.nextInt(1000)%128;
                   if((temp>=65 && temp<=90)||(temp>=97 && temp<=122)||(temp>=48 && temp<=57))
                             pass[cnt]=(char)temp;
                             cnt++;               
                        if(cnt>=len) break;
                   String newpass= pass.toString();
                   String newpass1= new String(pass);
                   System.out.println("passed pass"+newpass+"as"+newpass1+"sa");
              return newpass;
    here newpass and newpass1 are having separate values
    why ??
    Edited by: Shovan on Jun 4, 2008 2:21 AM

  • How to convert java map collection to flex arraycollection

    Dear all:
    as title, any sample code?  thank for helping
    java map [{"id":140,"state":"Alabama","obama":6,"mccain":5,"ec":3},
                   {"id":91,"state":"Alaska","obama":4,"mccain":5,"ec":3}

    I think the closes thing to an .exe in Java is developing you program as an application, and packing it into an "executable jar" file.

  • Error 1034: Converting movie clip to instance of a custom object?

    I have several movie clips on the stage that each have unique instance names.
    I need to instantiate them as instances of a custom class I have created. This is giving me an error, and I know I'm probably missing some simple concept somewhere, doing something wrong, but I don't know what it is.
    Here is my code:
    In the main timeline, I have (simplified):
    var puzzleAL:GeoGroup = new GeoGroup ("AL", "Alabama", 1, false);
    puzzleAL.addEventListener(TouchEvent.TOUCH_BEGIN, geoTouchBeginHandler);
    function geoTouchBeginHandler (e:TouchEvent): void {
        e.target.gotoAndStop("Over");
        nameDisplay.gotoAndStop(e.target.abbrev);
        e.target.addEventListener(TouchEvent.TOUCH_END, geoTouchEndHandler);
    function geoTouchEndHandler (e:TouchEvent): void {
        if (e.target.lock == false) {
            e.target.gotoAndStop("Off");
        else if (e.target.lock == true) {
            e.target.gotoAndStop("Lock");
        nameDisplay.gotoAndStop("USA");
        e.target.removeEventListener(TouchEvent.TOUCH_END, geoTouchEndHandler);
    It throws an error before the object is ever instantiated. It compiles, but at runtime I get:
    TypeError: Error #1034: Type Coercion failed: cannot convert Puzzleography_fla::Alaska_2@da0a0f9 to GeoGroup.
         at flash.display::MovieClip/gotoAndStop()
         at Puzzleography_fla::MainTimeline/goToFrame()
    My class code looks like this, if it matters:
    package  {
        import flash.display.MovieClip;
        public class GeoGroup extends MovieClip {
            public var abbrev:String;
            public var fullName:String;
            public var assignedOrder:Number;
            public var lock:Boolean;
            public function GeoGroup(abbrev:String, fullName:String, assignedOrder:Number, lock:Boolean) {
                this.abbrev = abbrev;
                this.fullName = fullName;
                this.assignedOrder = assignedOrder;
                this.lock = lock;
    I'm missing something obvious, I know it, but I'm new to OOP, switching from procedural, so I'm sure I'm getting a concept wrong somewhere.
    Thanks so much!
    Amber

    yes, it makes sense and yes, you'll need to learn a little.
    I have 50 movie clips not linked to any actionscript in the movie.
    that's incorrect.  those movieclips are linked to all the actionscript that applies to their class.  so, even if those movieclips weren't part of the GeoClass, they still have all the properties, methods and events of the movieclip class (created by adobe developers).
    The fact these movieclips are actually GeoGroup objects extending the movieclip class, adds even more code to them.  and, so far that's all good and exactly what you should do.
    They are all on the stage. They are all named with their instance names "puzzleAZ" "puzzleTX" etc.
    no problem, usually.  (but in your case, a problem explained below.)
    I want to be able to add variables to them, such as strings and numbers, so that I can call puzzleAZ.size or puzzleAZ.fullName to get "XX Acres" or "Arizona" returned.
    so, in programming lingo you want your objects to be members of a dynamic (ie, you can add properties) class.  the movieclip class is just such a class.
    I created a separate class (GeoGroup) that extends MovieClip that has in it all the variables I need and tried to assign each movie clip to that class.
    here's the problem.  when you created your GeoGroup class you mandated that certain parameters be passed to the constructor.  when you add a class member (like each of those puzzle pieces) to the stage, the class constructor is invoked (along with everything else in that class).  However, no parameters are passed to your constructor so the flash compiler points out the issue and refuses to run your code.
    there are two ways you could proceed:
    1.  remove the parameters from the constructor
    2.  don't add any class members to the stage in the authoring environment.
    p.s.  this is your GeoGroup constructor:
          public function GeoGroup(abbrev:String, fullName:String, assignedOrder:Number, lock:Boolean) {
                this.abbrev = abbrev;
                this.fullName = fullName;
                this.assignedOrder = assignedOrder;
                this.lock = lock;
    the paramters that contructor requires are 2 strings, one number and one boolean.

  • How to convert Windows 8.1 .exe file to ISO image for installation via Boot Camp?

    I have a late 2013 retina display MacBook Pro and want to use Boot Camp to run one piece of software that is run exclusively on Windows operating systems.  I have a Windows 8.1 download from MS that is an .exe file, and I need to convert it (I believe) to an ISO image on a flash drive.  How do I convert the .exe file to an ISO image?

    If you want to use Mac OS X at the same time as Windows, run one of these:
    VMWare Fusion
    Parallels
    Virtual Box (Open Source)
    If you are willing to alternate Boot Windows -OR- Mac OS X, all you need is Bootcamp Assistant (and your Windows installer, of course.)
    >>NB In any case, do not allow Windows to directly modify the Partition Map or change the size of any Partition. That will wipe out the Partition Map, and Mac OS X. Windows is not a pleasant guest.

Maybe you are looking for

  • Lead time for Item / Weekends

    Hi I am confused about the lead time to be entered for the item planning/MRP. Do I include weekends when entering lead times in Items master data or not? 2 weeks = 10 days or 14 days? In MRP I can select to respect Holidays. Does that also influence

  • Unicode character doesn't display integral symbol

    I tried using unicode character 222B in my program to get the integral symbol. It works well in jdk1.2, but if i try to run the same program in jdk1.3 , it's returning delta symbol. What is the possible solution, such that i get the integral symbol i

  • Align By Page in 11.5

    I have noticed in 11.5 that the option to align a group of objects by the page margins while keeping the objects relative to each other is gone. Please tell me this option is just hidden somewhere and is still available! Blanchard

  • Cursor Style, Forms Web Implementation 6.0

    I am using the Forms server 6.0 with static HTML to display forms over Intranet. The cursor styles through SET APPLICATION PROPERTY builtin does not seem to change the cursor in the browser. (Works fine when I test the form in Client/Server environme

  • Wsimport multiple wsdl problem

    Hello, I have been using wsimport successfully to generate a class library based on a wsdl file. The application hits 2 different web services on the same server which I have no control over, and each of these web services use a common xsd. Therefore