hello!

i would prefer the first option. ;)

i changed my code to this:

        callAsync: function( method, args )
        {
            var handler = function( result, exc, id )
            {
                if ( exc == null )
                {
                    //alert( result );
                }
                else {
                    alert( "RPC-Exception: " + exc + " ( ID: " + id + ")" );
                }
            };
            
            this.__rpcRunning = this.__rpc.callAsync( handler, method, args
);
            
            this.__rpc.addListener( "completed", function(e)
            {
                this.__result = e.getData();
            }, this );
            
            alert( this.__result );
        }

but i get "null" as value .. whats wrong? :)


Noggin182 wrote:
> 
> Hi Again,
> The call to the backend is asyncrounous, your 
> qxgui.utils.Rpc.callAsync() function will return immediately.
> 
> There are two ways forward, you can either change your class so it fires 
> an "complete" event, or change the function so it accepts a callback.
> 
>  From the callAsync() function it looks like you are expierenced enough 
> to do either without help.
> 
> The two choices would make your calling code look like this:
> 
> Option 1.)
> 
> var rpc = new qxgui.utils.Rpc;
> rpc.callAsync( "doLogin", [ username, userpw ] );
> rpc.addListener("complete", function(e)
> {
>    var result = e.getData();
> });
> 
> Option 2.)
> 
> var rpc = new qxgui.utils.Rpc;
> rpc.callAsync( "doLogin", [ username, userpw ], function(result)
> {
>    alert(result);
> });
> 
> 
> If you need more help, just decide first which one best meets your 
> requirements and let us know :)
> 
> HTH,
> Matt
> 
> 
> sNIk wrote:
>> hello there. i want to simplify the usage of rpc and ran into a problem
>> with
>> the handler. example:
>> 
>> usage:
>> -------------------------------------------------------------------------------------
>> 
>> var rpc = new qxgui.utils.Rpc;
>> rpc.callAsync( "doLogin", [ username, userpw ] );
>> var result = rpc.getResult();
>> 
>> 
>> class:
>> -------------------------------------------------------------------------------------
>> 
>> qx.Class.define("qxgui.utils.Rpc",
>> {
>>     extend: qx.core.Object,
>>     
>>     construct: function( url, service )
>>     {
>>         // standard-paramenter
>>        some statements ...
>>         
>>         // konfigurieren
>>         rpc = new qx.io.remote.Rpc( url, service );
>>         
>>         rpc.setTimeout( this.__timeout );
>>         rpc.setCrossDomain( this.__crossDomain );
>>         
>>         this.__rpc = rpc;
>>     },
>>     
>>     members:
>>     {
>>         // eigenschaften
>>        
>> ////////////////////////////////////////////////////////////////////////
>>         
>>         __url: "xxx",
>>         __service: "xxx",
>>         __timeout: 5000,
>>         __crossDomain: true,
>>         
>>         __rpc: null,
>>         __id: null,
>>         __exc: null,
>>         __result: null,
>>         __rpcRunning: null,
>>         
>>         
>>         // methoden
>>        
>> ////////////////////////////////////////////////////////////////////////
>>         
>>         callAsync: function( method, args )
>>         {
>>             var handler = function( result, exc, id )
>>             {
>>                 if ( exc == null )
>>                 {
>>                     this.__result = result;
>>                 }
>>                 else {
>>                     alert( "RPC-Exception: " + exc );
>>                 }
>>             };
>>             
>>             this.__rpcRunning = this.__rpc.callAsync( handler, method,
>> args
>> );
>>         },
>>         
>>         isRpcRunning: function()
>>         {
>>             return this.__rpcRunning;
>>         },
>>         
>>         getResult: function()
>>         {
>>             return this.__result;
>>         }
>>     }
>> });
>> 
>> 
>> how do i get the result into the right scope?
> 
> 
> ------------------------------------------------------------------------------
> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
> production scanning environment may not be a perfect world - but thanks to
> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK
> i700
> Series Scanner you'll get full speed at 300 dpi even with all image 
> processing features enabled. http://p.sf.net/sfu/kodak-com
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
> 
> 

-- 
View this message in context: 
http://n2.nabble.com/problems-with-rpc-abstraction-%28-using-this-in-callback-function-%29-tp2792185p2792389.html
Sent from the qooxdoo mailing list archive at Nabble.com.


------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to