6 Replies Latest reply on Jan 27, 2009 10:22 AM by Newsgroup_User

    Flex passing sturctures doesn't work anymore

    KomputerMan.com Level 1
      Something has changed in the calls I make to my ColdFusion datasources but I don’t know what. What I do know is that these calls have worked for over 6 months and then quit working recently, as in I noticed the problem this morning while I was making a change for my customer. This problem has effected ALL of my Flex applications even though most of them have not had changes for weeks or months now. I have examples of code below which used to work fine but now fails.

      The problem seems to be in the structures I use to pass my variables to my database web service. Basically I pass in a structure of variables from Flex to my CFC. Below is an example of the calls I am using to pass my variables to my CFC from inside my Flex app:

      private function contactInfoAddedHandler(event:AddContactInfoEvent):void
      {
      addTmpData.modContactInfo(event.contactInfoToAdd);
      }

      This type of call (of which I have MANY) worked fine for months, now they fail. The problem is how the data gets received by the CFC. In the CFC’s I tell the app that is should expect a structure with my variables to be passed in. This is the header code in my CFC for this call:

      <cffunction name="modContactInfo" access="remote" returntype="string">
      <cfargument name="ContactInfo" type="struct" required="yes">
      … database code…
      </cffunction>


      Now for the problem… in the modContactInfo function the CFC receives the data as a bunch of individual arguments instead of a structure of elements. It used to receive one structure with all of the elements inside of the structure. I have no idea why the CFC now receives the data elements as a bunch of separate elements instead of the structure.

      To fix the problem all I have to do is change my argument calls inside the function from this: “arguments.ContactInfo.CellPhoneNumber” to this” “arguments.CellPhoneNumber”. But I don’t want to do that… I would rather deal with one passed structure than a whole slew of variables.

      My question is why does the CFC now receive a bunch of individual elements instead of the structure??? When I debug the Flex application and look at the data it is properly contained within its event. Does anybody have an idea as to what could cause this problem, or more importantly how to fix it??? Oh, my client is using CF 7.02 and the app is compiled using Flex 3.0 if that helps… Thanks in advance for your insights…
        • 1. Re: Flex passing sturctures doesn't work anymore
          Level 7

          "KomputerMan.com" <webforumsuser@macromedia.com> wrote in message
          news:gldjfb$jr0$1@forums.macromedia.com...
          > Something has changed in the calls I make to my ColdFusion datasources but
          > I
          > don?t know what. What I do know is that these calls have worked for over 6
          > months and then quit working recently, as in I noticed the problem this
          > morning
          > while I was making a change for my customer. This problem has effected
          > ALL of
          > my Flex applications even though most of them have not had changes for
          > weeks or
          > months now. I have examples of code below which used to work fine but now
          > fails.
          >
          > The problem seems to be in the structures I use to pass my variables to my
          > database web service. Basically I pass in a structure of variables from
          > Flex to
          > my CFC. Below is an example of the calls I am using to pass my variables
          > to my
          > CFC from inside my Flex app:
          >
          > private function contactInfoAddedHandler(event:AddContactInfoEvent):void
          > {
          > addTmpData.modContactInfo(event.contactInfoToAdd);
          > }
          >
          > This type of call (of which I have MANY) worked fine for months, now they
          > fail. The problem is how the data gets received by the CFC. In the CFC?s
          > I
          > tell the app that is should expect a structure with my variables to be
          > passed
          > in. This is the header code in my CFC for this call:
          >
          > <cffunction name="modContactInfo" access="remote" returntype="string">
          > <cfargument name="ContactInfo" type="struct" required="yes">
          > ? database code?
          > </cffunction>
          >
          >
          > Now for the problem? in the modContactInfo function the CFC receives the
          > data
          > as a bunch of individual arguments instead of a structure of elements. It
          > used
          > to receive one structure with all of the elements inside of the structure.
          > I
          > have no idea why the CFC now receives the data elements as a bunch of
          > separate
          > elements instead of the structure.
          >
          > To fix the problem all I have to do is change my argument calls inside the
          > function from this: ?arguments.ContactInfo.CellPhoneNumber? to this?
          > ?arguments.CellPhoneNumber?. But I don?t want to do that? I would rather
          > deal
          > with one passed structure than a whole slew of variables.
          >
          > My question is why does the CFC now receive a bunch of individual elements
          > instead of the structure??? When I debug the Flex application and look at
          > the
          > data it is properly contained within its event. Does anybody have an idea
          > as to
          > what could cause this problem, or more importantly how to fix it??? Oh, my
          > client is using CF 7.02 and the app is compiled using Flex 3.0 if that
          > helps?
          > Thanks in advance for your insights?

          At a guess, I would say that maybe your RemoteClassAlias doesn't match
          whatever AMF on CF uses to match up the AS class to the CF class. If
          nothing about that has changed, I'd look to see if something about the
          server has changed.

          HTH;

          Amy


          • 2. Re: Flex passing sturctures doesn't work anymore
            KomputerMan.com Level 1
            I don't think that is the problem. My variables still show up in the CFC they just are not encapsulated inside of a structure anymore. Very FRUSTRATING!!! As in why did I choose Flex over C# again...
            • 3. Re: Flex passing sturctures doesn't work anymore
              AlHolden Level 1
              Does this correspond to a change in compiler? From Flex 2 to 3 for example?
              Were there any recent changes to your WebService platform? A change in ColdFusion versions or builds (or from CF to Blue Dragon)?
              If you're talking about Flex apps that have never changed or been re-compiled in months - but are also members of this "family of buggy structures", then it would seem that the problem is confined to some change in server technology...
              • 4. Re: Flex passing sturctures doesn't work anymore
                John Hall Level 4
                I know this is probably a red herring but I had some buggy stuff like that happen to me the other day until I removed the Arguments. after the parameter declaration. I don't know the proper approach (I know, Google) but once I switch from something similar to your arguments.ContactInfo.CellPhoneNumber to contactInfo.cellPhoneNumber in all the cfml after the <cfparameter>, I haven't had problems. And yes, it had worked some with Arguments. before. Maybe I added another object coming in or something. On the other hand, I wasn't mapping to VOs on the coldfusion site, just sending in an objectProxy. If you've mapped VOs in CF, this is probably unrelated.

                Oh well, just another data point in your search. Still have to think something has changed on the server.
                • 5. Re: Flex passing sturctures doesn't work anymore
                  KomputerMan.com Level 1
                  I am beginning to think this is a bug in Flex itself. The reason I say that is I have two examples of code where the object is passed to the CFC as a structure and one time as an object. Let me explain with some code. I am including the guts of two functions that write to a backend database. The first one, that fails, writes the answers to some questions that the end user needs to answer to get a license issued to them. The second function (that works) is called when the end user wishes to modify their address information.

                  First lets look at the datamodels for each function. The renew questions datamodel is listed first followed by the address datamodel.

                  Next look at the event that is called for each function. The renew questions event is shown first followed by the address event.

                  Next look at how the metadata tags dispatch the event from within the *.mxml templates. The metadata tags are shown first followed by three of the actionscript lines that kick the event off. I am leaving out a bunch of the fill in the variable stuff just to make it easier to read. Once again the renew dispatch code is listed first followed by the address dispatch stuff.

                  Next I list the listeners inside the main mxml template and then show the actionscript that gets called by the listener.

                  Finally I am listing the CFC cffunction header information for each called function.

                  I just installed the service capture software from the http://www.kevinlangdon.com/serviceCapture/ web site. This is way easy to use software that shows me what stuff is being passed back and forth from my Flex app and my CF server. For the address call, which works, the "Type" that shows up in the Remoting tab is listed as "IREC_Flex.WebServices.TransferData" For the renew questions call, which fails, the "Type" is listed as "Object". The name for both of the calls is listed as "Parameter 1". All of the variables arrive at the CFC with their proper values. Only difference is in the address cffunction I call out the variables using this notation: arguments.AddrInfo.Address In the Renew questions cfc I have to drop out the second name of my variable string and call out each variable like this: arguments.license_number. Problem is it worked for seven months using this notation: arguments.RQInfo.license_number.

                  As I see no discernable difference in the code (other than the obvious variable naming stuff) but I do see a difference in the call as it is being made... I have to assume that something in Flex is a bit buggered up.

                  Any thoughts or am I just blind and you can spot my glaring error??? :)


                  • 6. Re: Flex passing sturctures doesn't work anymore
                    Level 7

                    "KomputerMan.com" <webforumsuser@macromedia.com> wrote in message
                    news:glniui$15v$1@forums.macromedia.com...
                    >I am beginning to think this is a bug in Flex itself. The reason I say
                    >that is
                    > I have two examples of code where the object is passed to the CFC as a
                    > structure and one time as an object. Let me explain with some code. I am
                    > including the guts of two functions that write to a backend database. The
                    > first one, that fails, writes the answers to some questions that the end
                    > user
                    > needs to answer to get a license issued to them. The second function
                    > (that
                    > works) is called when the end user wishes to modify their address
                    > information.
                    >
                    > First lets look at the datamodels for each function. The renew questions
                    > datamodel is listed first followed by the address datamodel.
                    >
                    > Next look at the event that is called for each function. The renew
                    > questions
                    > event is shown first followed by the address event.
                    >
                    > Next look at how the metadata tags dispatch the event from within the
                    > *.mxml
                    > templates. The metadata tags are shown first followed by three of the
                    > actionscript lines that kick the event off. I am leaving out a bunch of
                    > the
                    > fill in the variable stuff just to make it easier to read. Once again the
                    > renew
                    > dispatch code is listed first followed by the address dispatch stuff.
                    >
                    > Next I list the listeners inside the main mxml template and then show the
                    > actionscript that gets called by the listener.
                    >
                    > Finally I am listing the CFC cffunction header information for each called
                    > function.

                    I don't see where you're setting the ColdFusion equivalent part of the
                    RemoteClassAlias.