1

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.

4

2 回答 2

1

ComboBox 类上有一个名为 labelField 的属性。继续并将其设置为返回数据的名称字段。如果这不起作用 - 您需要从 CF 调试返回的值 - 以确保 name 属性实际上也被填充在客户端。

此外,您的数据可能以数组(而不是 ArrayCollection)的形式返回 - 在这种情况下,您需要设置:

qryStuff = ArrayCollection( event.result as Array );

注意:您可能还希望通过创建一个 ActionScript 值对象来“强类型化”您的响应数据 - 这样它就不仅仅是从 CF 返回的通用“对象”。然后,您可以使用 [RemoteClass(alias="com.sample.MyCFC")] 元数据标签将该值对象映射到您的服务器端 VO。

于 2009-09-29T20:55:14.013 回答
0

在我的 cfc 中,我必须明确设置数据/标签。

于 2009-10-12T20:39:44.220 回答