10 Replies Latest reply on Aug 13, 2009 7:54 AM by wrkoch

    Datagrid to CFC

    LukeDD Level 1

      I've been waisting alot of time on this.

       

      I'm trying to pass and arrayCollection and pass it to a cfc. The arrayCollection is taken from a dataGrid.

       

      Flex Function

       

      private function publishToProduction(appID:Number):void{
          var devQ:ArrayCollection = dgHelpLs.dataProvider as ArrayCollection;
          roTKLib.pushToProduction.send(devQ);
      }

       

       

      CFC function

      <cffunction name="pushToProduction">
              <cfargument name="devQ" type="any" required="yes" />
              <cfsavecontent variable="content.x">
                  <cfdump var="#arguments.devQ#">
              </cfsavecontent>
              <cffile action="write" output="#content.x#" file="#expandPath('query.html')#">

      </function>

       

      My problem that when the arraycollection is passed to the CFC, one it's not recognised as a query, and two is empty. Any idea what the problem might be?

        • 1. Re: Datagrid to CFC
          Michael Borbor Level 4

          Verify that the data is sent correctly from flex and in cf you acces 

          the ac as myobj[1]

           

          Sincerely,

           

          Michael

           

          El 17/04/2009, a las 10:48, LukeDD <forums@adobe.com> escribió:

           

          >

          I've been waisting alot of time on this.

          >

          I'm trying to pass and arrayCollection and pass it to a cfc. The 

          arrayCollection is taken from a dataGrid.

          >

          private function publishToProduction(appID:Number):void{

              var devQ:ArrayCollection = dgHelpLs.dataProvider as 

          ArrayCollection;

              roTKLib.pushToProduction.send(devQ);

          }

          >

          My problem that when the arraycollection is passed to the CFC, one 

          it's not recognised as a query, and two is empty.

          >

          • 2. Re: Datagrid to CFC
            LukeDD Level 1

            Seems that my problem is that Flex is not passing the data? But Why?

            • 3. Re: Datagrid to CFC
              LukeDD Level 1

              I changed:

              var devQ:String = 'test';

               

              that worked so the problem is getting the data from the grid. any idea?

              • 4. Re: Datagrid to CFC
                Michael Borbor Level 4

                Try passing it like this

                 

                var devQ:ArrayCollection = new ArrayCollection(dgHelpLs.dataProvider)

                 

                Sincerely,

                 

                Michael

                 

                El 17/04/2009, a las 10:48, LukeDD <forums@adobe.com> escribió:

                 

                >

                I've been waisting alot of time on this.

                >

                I'm trying to pass and arrayCollection and pass it to a cfc. The 

                arrayCollection is taken from a dataGrid.

                >

                private function publishToProduction(appID:Number):void{

                    var devQ:ArrayCollection = dgHelpLs.dataProvider as 

                ArrayCollection;

                    roTKLib.pushToProduction.send(devQ);

                }

                >

                My problem that when the arraycollection is passed to the CFC, one 

                it's not recognised as a query, and two is empty.

                >

                • 5. Re: Datagrid to CFC
                  LukeDD Level 1

                  now getting 1118: Implicit coercion of a value with static type Object to a possibly unrelated type Array.

                  • 6. Re: Datagrid to CFC
                    EvolvedDSM Level 2

                    Can you verify that devQ is actually holding a value from your publishToProduction method?  Comment out your remoteObject command and add code to output devQ on your screen -- just to ensure there's actually data to collect and send.

                     

                    Also, can you try removing send()?  Try using roTKLib.pushToProduction(devQ);

                     

                    In your CFC within your cffunction and between cfargument and cfsavecontent, set up a <cfif> that checks the devQ.length EQ 0.  Something like...

                    <cfif arguments.devQ.length EQ 0>

                         <cfthrow type="conflict" message="devQ is empty">

                    <cfelse>

                         ...what you want to do with devQ...

                    </cfif>

                     

                    I'm not 100% that arguments.devQ.length is the proper way to check the length of the argument, but you should get the idea.  The purpose of the CFIF is to return a message saying there's NOTHING stored in devQ.

                     

                    Edited for typo's.

                    • 7. Re: Datagrid to CFC
                      LukeDD Level 1

                      AHH finally. You got me on the right track.

                       

                      I did

                       

                      var devQ:ArrayCollection = new ArrayCollection();
                      devQ = dgHelpLs.dataProvider as ArrayCollection;

                       

                      And that worked like a charm.

                       

                      Thank you Michael Borbor

                      • 8. Re: Datagrid to CFC
                        Michael Borbor Level 4

                        Great!

                         

                        Sincerely,

                         

                        Michael

                         

                        El 17/04/2009, a las 12:16, LukeDD <forums@adobe.com> escribió:

                         

                        >

                        AHH finally. You got me on the right track.

                        >

                        I did

                        >

                        var devQ:ArrayCollection = new ArrayCollection();

                        devQ = dgHelpLs.dataProvider as ArrayCollection;

                        >

                        And that worked like a charm.

                        >

                        • 9. Re: Datagrid to CFC
                          Michael Borbor Level 4

                          Please close this thread.

                          • 10. Re: Datagrid to CFC
                            wrkoch

                            I've been trying to do something similar.  I did exactly the same thing.  When I interrogate the "devQ" argument in the CFC, I find it is an array of structures.  The docs imply it should be a query object.  And I need it to be a query object

                             

                            How can I get this thing to appear in the CFC as a query object?

                             

                            Thanks!

                             

                            Warren Koch