我已经按照本教程获取了一些 Flex 代码来调用托管在 Tomcat 服务器上的 Java 代码。
这就是我的 RemoteObject 和调用远程函数的按钮的声明方式:
<mx:RemoteObject id="productService" destination="productJavaService" result="resultHandler(event)" fault="faultHandler(event)"/>
<mx:Button label="Get all Products" click="productService.getAllProducts()" />
这些是 resultHandler 和 faultHandler 函数的定义:
private function resultHandler(event:ResultEvent):void
{
products = event.result as ArrayCollection;
}
private function faultHandler(event:FaultEvent):void
{
Alert.show(event.fault.faultString);
}
对我来说,明显的问题是 resultHandler 与 RemoteObject 作为一个整体而不是单个函数相关联。如果我添加一个新函数,例如“getSingleProduct”,那么显然需要使用不同的 resultHandler。如何在函数级别指定 resultHandler?