1
votes

I have the following:

 <mx:RemoteObject id="myCFC" destination="ColdFusion" source="components.myCFC"  showBusyCursor="true">
    <mx:method name="getStuff" result="UserHandler(event);"/>
</mx:RemoteObject>

...
<mx:ComboBox id="propertyCode" dataProvider="{qry_stuff}" labelField="name" />

Index.as has:

   [Bindable] public var qry_stuff:ArrayCollection = new ArrayCollection;

 private function UserHandler(event:ResultEvent):void {
   qry_stuff= event.result as ArrayCollection;
 }

public function init():void {
  /* call my remote Object to get my data */
   myCFC.getStuff();
  }

my problem is the combobox displays [object Object]

I know there is nothing wrong with the cfc and there is a field called "name" in getStuff. Why does it not display the value of the object? thanks in advance.

2
What is the structure of event.result? I'm guessing the problem is in creating the ArrayCollection. You could also check the size of the ArrayCollection.Glenn
The size of the ArrayCollection seem to be right. (it equals to the number of records coming out of the query). Not sure what event.result is/. I copy/pasted/modified this code from blog.tygate.com/?p=463 please let me know what you think.CFNinja
Have you tried using other thing as labelField? Can the ComboBox display that "other thing"?Andy Li

2 Answers

1
votes

There is a property on the ComboBox class called labelField. Go ahead and set that to the name field on the data that is returned. If that doesn't work - you need to debug your returned values from CF - to be sure that the name property is actually being populated on the client side as well.

In addition, you data is probably being returned as an array (not an ArrayCollection) - in which case, you would need to set:

qryStuff = ArrayCollection( event.result as Array );

Note: You probably also want to 'strong-type' your response data by creating an ActionScript value object - so that it is not just a generic 'object' that is being returned from CF. You then can use the [RemoteClass(alias="com.sample.MyCFC")] metadata tag to map that value object to your server-side VO.

0
votes

In my cfc, I had to explicitly set data/label.