开发者

Occurrence of ResultEvent event in remoting a spring Object

In my attempt to learn flex remoting I came across this

flexService.getRules.addEventListener(ResultEvent.RESULT, loadRules);

here flexService is a remote java object .. In above function call can any one help me that开发者_JS百科 when ResultEvent.RESULT will occur. On studying about ResultEvent in AS document it states as

The event that indicates an RPC operation has successfully returned a result

So keeping that in mind my guess is ResultEvent will be fired when flexService.getRules method will successfully return a list of object,where flexService is object of remote class FlexService having getRules function which returns list of object, Can any one please tell how exactly it works.. Also can some one plz tell me how eventListener can be added to a list of object

PS: I am using Spring as backend


Here you set result to arraycollection

private function loadRules(event:ResultEvent):void
{
    var list:ArrayCollection = new ArrayCollection();
    list = event.result as ArrayCollection;
}


I'll be going on assumptions since you apparently aren't keen on showing more code or giving pertinent information.

  • I'm assuming that 'flexService' is a RemoteObject that has set all required properties (destination, endpoint, etc)
  • I'm assuming that 'getRules' is an available function on your java remote class which returns the information needed.
  • I'm assuming that everything is being sent over using AMF.

in that case, it's as simple as doing this:

var token:ASyncToken = flexService.getRules(arg1, arg2);
token.addResponder(new Responder(yourResultFunction, yourFaultFunction));

private function yourResultFunction(data:Object):void
{
   // Do something with data here
}

private function yourFaultFunction(fault:Object):void
{
   // do something if a fault happens
}

Of course, this is very basic and you should try to implement a better pattern (commands) around it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜