Flex/BlazeDS - 每个函数调用的 resultHandler 而不是每个 RemoteObject?
我按照此教程获取一些 Flex 代码来调用 Java代码托管在 Tomcat 服务器上。
这就是我的 RemoteObject 和调用远程函数的 Button 的声明方式:
<mx:RemoteObject id="productService" destination="productJavaService" result="resultHandler(event)" fault="faultHandler(event)"/>
<mx:Button label="Get all Products" click="productService.getAllProducts()" />
这些是 resultHandler 和 failureHandler 函数的定义:
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?
I've followed this tutorial to get some Flex code to call Java code hosted on a Tomcat server.
This is how my RemoteObject and the Button to call the remote function is declared:
<mx:RemoteObject id="productService" destination="productJavaService" result="resultHandler(event)" fault="faultHandler(event)"/>
<mx:Button label="Get all Products" click="productService.getAllProducts()" />
These are the definitions of the resultHandler and faultHandler functions:
private function resultHandler(event:ResultEvent):void
{
products = event.result as ArrayCollection;
}
private function faultHandler(event:FaultEvent):void
{
Alert.show(event.fault.faultString);
}
The obvious problem with this for me is that the resultHandler is associated with the RemoteObject as a whole rather than the individual function. If I add a new function such as "getSingleProduct" then obviously a different resultHandler will need to be used. How do I specify the resultHandler at function level?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在
RemoteObject
下定义method
属性,在您的情况下,它将是getAllProducts()
; 你可以这样做:You can define a
method
property under aRemoteObject
, in your case, it would begetAllProducts()
; You can do so like this:只是想添加:如果有人想使用 actionscript 实现此目的,您可以通过将 Responder 添加到从服务调用返回的 AsyncToken 来使用 actionscript 来实现此目的:
Just wanted to add: in case anyone wants to achieve this with actionscript, you can do this with actionscript by adding a Responder to the AsyncToken returned from the service call: