views:

200

answers:

1

i am tring to load multiple tables on a flex page and cant seem to figure out how to use multiple remote objects.

Below is my coldfusion

<cfcomponent output="false">    
<cffunction name="getVacancies" access="remote" returntype="query">  
 <cfset var = qRead ="" /> 
 <cfquery datasource="sqlexpress" name="qRead">  
  SELECT Status, SFIELD6
  FROM dbo.VacantSumm
 </cfquery>
 <cfreturn qRead /> 
</cffunction>
<cffunction name="getVacancyTotals" access="remote" returntype="query">
 <cfset  var = vRead =""/>
 <cfquery datasource="sqlexpress" name="vRead">
  select Total, Status
  from dbo.VacancyTotal
 </cfquery>
 <cfreturn vRead />
</cffunction>

and now for my AS:

import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
      [Bindable]
      private var acVacancies:ArrayCollection;
      private var VacancyTotals:ArrayCollection;


      private function initApp():void
      { 
       VacancyGateway_RO.getVacancies();
       VacancyGateway_RO.getVacancyTotals();

      }
      private function getVacanciesRO_Handler(event:ResultEvent):void
      {
       acVacancies = ArrayCollection(event.result);
      }
      private function getVacancyTotalsRO_Handler(event:ResultEvent):void
      {
       VacancyTotals = ArrayCollection(event.result);
      }

I know kinda where my is, i think. the two arraycollections, any help on this would be great and highly appreciated.

A: 

It looks like your remote object definitions aren't included in the AS snippet above. Do you create them in another section of the code? If so, please add just that part so we can see how you are creating the object. You don't mention what error you are getting, if any; that would be helpful to know as well.

Also, I see you figured out you don't need to create a separate RemoteObject instance for each method in your CFC. A single instance will work for all of them, as long as you add a method element for each function. For example:

 <mx:RemoteObject
    id="VacancyGateway_RO"
    destination="ColdFusion"
    source="wherever.your.CFC.is.located">

    <mx:method name="getVacancies" result="getVacanciesRO_Handler(event)"
         fault="mx.controls.Alert.show(event.fault.faultString)"/>
    <mx:method name="getVacancyTotals" result="getVacancyTotalsRO_Handler()"
         fault="mx.controls.Alert.show(event.fault.faultString)"/>
</mx:RemoteObject>

I only mention that because I recently worked on a project where the previous developer(s) created a RemoteObject for every method they called ... and there were a lot of methods in some of the CFCs.

Dave DuPlantis