3 Replies Latest reply on Jun 21, 2008 2:50 PM by jedale

    Accessing Array of Structures from Coldfusion

    jedale Level 1
      I am having a problem accessing an array of structures from Coldfusion within my flex application. Here is how I make my Array: (GetRegions is a type Query and Type is a string variable)
      <cfset ReturnArray = ArrayNew(1)>
      <cfset ReturnArray[1] = StructNew()>
      <cfset ReturnArray[1].Query = GetRegions>
      <cfset ReturnArray[2] = Type>

      Within flex I am trying to access the results in the following way:
      private function dataHandler(event:ResultEvent):void{
      Query_Filter = new ArrayCollection(event.result[0].QUERY as Array);
      myString = event.result[1] as String;
      }

      Can anybody help me with this. I want a way to return a query and a string back from coldfusion.

      Thanks for the help,
      Jeff
        • 1. Re: Accessing Array of Structures from Coldfusion
          jedale Level 1
          So either nobody knows how to do this, or it isn't possible to send this to flex through remoting. Does anybody know how to send two data types over the same return remoting call? I know I can just set my string as another column in the query but this doesn't seem to elegant.

          Thanks for any and all help,
          Jeff
          • 2. Re: Accessing Array of Structures from Coldfusion
            jedale Level 1
            So now I changed my code to the following in CF:
            <cfset Type = "MyString">
            <cfset ReturnArray = ArrayNew(1)>
            <cfset ReturnArray[1] = StructNew()>
            <!--- set up query GetRegions --->
            <cfset ReturnArray[1] = GetRegions>
            <cfset ReturnArray[2] = Type>
            <!--- Return Array --->
            <cfreturn ReturnArray>

            Now in flex I have the following dataHandler Function:
            Alert.show("hello: "+ObjectUtil.toString(event.result[0]));
            Query_Filter = new ArrayCollection(event.result as Array);

            Now I set up a List box with Query_Filter as the dataprovider but the results aren't showing correctly. The first item in the list box is displayed as [object, Object], [object, Object] and the second item is my String.

            Does anybody know how to break up the query to a variable and the string to its own variable in the dataHandler function.

            Thanks for any and all help
            • 3. Re: Accessing Array of Structures from Coldfusion
              jedale Level 1
              I found the following website saying that this is somethi9ng they are working on for CF 9 so apparently you can't do this directly.
              http://www.onflexwithcf.org/index.cfm/2007/8/11/ColdFusion-9-Wishlist