1 Reply Latest reply on May 20, 2008 10:40 AM by Bryan Dresselhaus

    reusing RemoteObject methods

    bfifield
      Hi,
      I'm using a RemoteObject (userService.CFC) to return data to combo-boxes.

      I would like to populate several arrays using the same method with different parameters
      i.e.

      userService.getUsersByDept('Marketing') or userService.getUsersByDept('Finance')

      My question is, what is the best method to handle the return set?

      I don't think that something like

      myArray = userService.getUsersByDept('Marketing') as Array;
      myOtherArray = userService.getUsersByDept('Finance') as Array;

      will work correctly, but I can't figure out how to handle populating different arrays with something like

      <mx:method name="getUsersByDept" result="handleReturnedUserResult(event)" .../>

      and keep the function and eventhandler generic. I don't want to have to hard-code the event handler with specific cases.

      Thanks, and any suggestions will be greatly appreciated.
      bri
        • 1. Re: reusing RemoteObject methods
          Bryan Dresselhaus Level 1
          userService.cfc should return a struct with two properties. The first should be the destination of the data (which combo box). The second should be the query recordset.

          Then when you receive the resultEvent to handleReturnedUserResult, you'll need to check the message body's destination property to determine what combobox in flex should have its dataProvider set. You can do this using if else statements or some sort of dynamic evaluation.