Flex:RemoteObject,传递命名参数

时间:2010-12-07 04:53:52

标签: flex coldfusion flex4

我正在使用Flex的RemoteObject方法调用ColdFusion cfc方法。

<fx:Declarations>
    <s:RemoteObject destination="ColdFusion" source="cfc.categoryGateway" id="categoryGateway">
        <s:method name="getCategoryList" result="returnHandler(event)"
                   fault="mx.controls.Alert.show(event.fault.faultString)">
            <s:arguments>
                <orderby>categoryId</orderby>
                <parentCategory>1</parentCategory>
            </s:arguments>
        </s:method>
    </s:RemoteObject>
</fx:Declarations>

我的cfc以下列方式接受参数:

<cffunction name="getCategoryList" access="remote" output="false" returntype="query">
    <cfargument name="parentCategory" type="string" required="false" />
    <cfargument name="orderby" type="string" required="false" />
    <!--- code... --->
    <cfreturn qCategoryList />
</cffunction>

所以当我调用cfc方法时,你可以看到我改变了参数的顺序。但它没有用。

这意味着<s:arguments>未传递命名的参数。 那有什么解决方案吗?正如您所看到的,我可能有一些非强制性的参数,因此必须按名称传递。

1 个答案:

答案 0 :(得分:2)

arguments参数是一个数组,所以无论你为每个元素命名,我认为它仍然会按顺序使用它。 您可以尝试这样做:

<s:RemoteObject destination="ColdFusion" source="cfc.categoryGateway" id="categoryGateway">
        <s:method name="getCategoryList" result="returnHandler(event)"
                  fault="mx.controls.Alert.show(event.fault.faultString)" />
    </s:RemoteObject>

然后致电:

categoryGateway.getCategoryList({orderby:'categoryId', parentCategory:'1'});
相关问题