5 Replies Latest reply on Oct 24, 2006 1:41 PM by davidmedifit



      I'm pretty new to flex.

      I have made a connection to a cfc via remoteobject

      <mx:RemoteObject id="cfService"

      <mx:Button label="Call ColdFusion" click="cfService.getArtistsAsQuery()" />

      This works fine.

      Now I also want to retrieve data from another cfc and put it into another destination.

      <mx:Button label="Call ColdFusion 2" click="cfService.getArtistsAsArray()" />

      But this puts the output in the same grid as the first one.

      What should I do if I want to use another grid for the second data?

      Do I have to make another RemoteObject?
      Or can I do something different on the 2 different results(result="dataHandler(event)”)?
        • 1. Re: &lt;mx:RemoteObject
          leotemp Level 1
          I dont think there is anything wrong with using multiple remote objects, you could also as you asked use a function on result to figure out what needs to occure and where the data should go but 2 remote objects would seem a bit easier
          • 2. Re: &lt;mx:RemoteObject
            kruse Level 1
            I would prefer to only use one remoteobject (I think).
            How can I do this.

            Or is it better to use multiple remoteobject for eatch cfc call?
            • 3. Re: &lt;mx:RemoteObject
              ntsiii Level 3
              You need to look into the ACT pattern. It allows you to set properties an an AsyncToken object when you call the data service, then access the property values when the data is returned in the generic result handler.

              One easy solution is to set a string id value when you make the call, then, in the resultHandler, use a switch statement based on that id to process the call results as you wish. You can even put a callback-like function itself in the AsyncToken property.

              Look for ACT (Asynchronous Call Token) in the docs.


              • 4. Re: &lt;mx:RemoteObject
                I'm pretty new to flex two too, but I think the problem is in your data handler. Is that where you are populating the datagrid? You are passing the results from both RemoteObject calls to the same data handler, and they are behaving the same way. Try creating a queryDataHandler(event) and a arrayDataHandler(event) function, and point each of them to a different dataGrid. I guess you would have to make two RemoteObjects, but that would get it done quickly and it wouldn't be too dirty.
                I don't know if that is according to best practices, but it should work.
                • 5. Re: &lt;mx:RemoteObject
                  davidmedifit Level 1
                  You want to do something like this?

                  <mx:method name="sayHelloString" result="handleHelloResult(event)"
                  <mx:method name="sayGoodbyeString" result="handleGoodbyeResult(event)"
                  <mx:method name="sayGetLostString" result="handleGetLostResult(event)"

                  You seem to know the code to call the functions properly, and handle the results, so I won't be redundant - let me know if I didn't answser your question fully.