Search This Blog

Friday, April 8, 2011

Flex Downloading data from database; mx.rpc.AsyncToken result object; Flex No data in AsyncToken.result field. Flashbuilder downloading data from database using RPC calls

When you use a service connected to db’s methods (get data from db) in flex you have to use rpc calls to get the data. When you just fire service.getSth() method it will return an AsyncToken object with nothing in AsyncToken.result field.

One way is to do something like this:

            var resultObj:AsyncToken;
            var responder:AsyncResponder = new AsyncResponder( resultHandlerAddInfo, faultHandlerAddInfo );
            //resultObj = testService.getTestIDForSpecLogId(int(logIDForViewingAddInfo));
            resultObj = testService.getAdditionalInfoForSpecLogId(int(logIDForViewingAddInfo));
            resultObj.addResponder( responder );
            public function resultHandlerAddInfo( event:ResultEvent, token:Object=null ):void
                // "RESULT: "+ event.result as String );
                var rpcRes:String = event.result as String;
                FlexGlobals.topLevelApplication.viewLogAddInfoVar.addInfoTextArea.text = rpcRes;
            public function faultHandlerAddInfo( event:FaultEvent, token:Object=null ):void
       "FAULT: " + event.fault.message );


1 comment:

  1. Very nice way to get result from AsyncToken.
    It really works....
    Thanks a lot...


If you like this post, please leave a comment :)