【问题标题】:Flex: RemoteObject, passing named parametersFlex:RemoteObject,传递命名参数
【发布时间】:2010-12-07 04:53:51
【问题描述】:

我正在使用 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方法时改变了参数的顺序。但它不起作用。

表示&lt;s:arguments&gt;没有传递named参数。 有什么解决办法吗?正如你所看到的,我可能有一些参数不是强制性的,所以它必须按名称传递。

【问题讨论】:

  • 您确定问题出在 flex 上吗?当 Flex 调用 cfc 方法时,您是否尝试将参数范围转储到文件中以查看其中的内容?
  • 是的,因为当我交换参数时,我在 SQL 查询中收到错误,例如:无法调用 CFC - CFSQLTYPE CF_SQL_INTEGER 的数据类别 ID 无效。
    parentCategory 实际上不是字符串参数,而是我在 SQL 查询中使用的整数参数。
    如果参数顺序相同,则完美运行。

标签: apache-flex coldfusion flex4


【解决方案1】:

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'});

【讨论】:

    猜你喜欢
    • 2017-07-13
    • 2015-03-03
    • 2011-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-22
    • 2010-09-20
    • 2011-10-23
    相关资源
    最近更新 更多