hello fritz. 

my problem was not understanding the syntax, please look at my code. ( var
rpc = new qxgui.utils.Rpc; <- my own rpc-layer. ;) ) i just didnt get it why
the property was null after a successfull request. noggin was able to
explain me why it didnt work.

hello noggin. thanks for your explanation. :)



Noggin182 wrote:
> 
> Just checked the API and the functiion I was refering to is 
> callAsyncListeners
> 
> Quote:
> callAsyncListeners(Boolean coalesce, String methodName)
> 
> Makes an asynchronous server call and dispatch an event upon completion 
> or failure. The method arguments (if any) follow after the method name 
> (as normal JavaScript arguments, separated by commas, not as an array).
> 
> When an answer from the server arrives (or fails to arrive on time), if 
> an exception occurred, a “failed”, “timeout” or “aborted” event, as 
> appropriate, is dispatched to any waiting event listeners. If no 
> exception occurred, a “completed” event is dispatched.
> 
> When a “failed”, “timeout” or “aborted” event is dispatched, the event 
> data contains an object with the properties ‘origin’, ‘code’, ‘message’ 
> and ‘id’. The object has a toString() function which may be called to 
> convert the exception to a string.
> 
> When a “completed” event is dispatched, the event data contains the 
> JSON-RPC result.
> 
> The return value of this method is a call reference that you can store 
> if you want to abort the request later on. This value should be treated 
> as opaque and can change completely in the future! The only thing you 
> can rely on is that the abort method will accept this reference and that 
> you can retrieve the sequence number of the request by invoking the 
> getSequenceNumber() method (see below).
> 
> If a specific method is being called, asynchronously, a number of times 
> in succession, the getSequenceNumber() method may be used to 
> disambiguate which request a response corresponds to. The sequence 
> number value is a value which increments with each request.)
> Parameters:
> coalesce
> 
> coalesce all failure types (“failed”, “timeout”, and “aborted”) to 
> “failed”. This is reasonable in many cases, as the provided exception 
> contains adequate disambiguating information.
> methodName
> 
> the name of the method to call.
> Returns:
> 
> 
> 
> 
> 
> Fritz Zaucker wrote:
>>> From http://demo.qooxdoo.org/0.8.x/apiviewer/#qx.io.remote.Rpc~callAsync
>> 
>> callAsync(Function handler, String methodName)
>> 
>> Makes an asynchronous server call. The method arguments (if any) follow
>> after the method name (as normal JavaScript arguments, separated by
>> commas,
>> not as an array).
>> 
>> When an answer from the server arrives, the handler function is called
>> with
>> the result of the call as the first, an exception as the second
>> parameter,
>> and the id (aka sequence number) of the invoking request as the third
>> parameter. If the call was successful, the second parameter is null. If
>> there was a problem, the second parameter contains an exception, and the
>> first one is null.
>> 
>> Parameters:
>> handler
>>     the callback function.
>> methodName
>>     the name of the method to call.
>> 
>> 
>> 
>> So I think your code could be something like that:
>> 
>> var getMenuHandler = function (data, exc,id) {
>>            if (exc == null) {
>>              // whatever you want to do
>>            }
>>            else { // the async call failed
>>                alert(exc);
>>            }
>>       };
>> 
>> rpc.callAsync( getMenuHandler, "getMenuXml", null );
>> 
>> You could pass an parameter to the remote method instead of null.
>> 
>> Cheers,
>> Fritz
>> 
>> On Wed, 6 May 2009, Matthew Gregory wrote:
>> 
>>> I haven't got the api in front of me but I think there is a different
>>> function to use callback handlers. Instead of callAsync something like
>>> "callWithHandlers"
>>>
>>> sNIk wrote:
>>>> oh .. got it now. ive never done async-stuff, so i must rethink as u 
>>>> said. ;)
>>>> actually im not a webapp-programmer, its not hard but different than
>>>> programming a game or demo. no back to topic ;)
>>>>
>>>>
>>>> my approach:
>>>>
>>>> var rpc = new qxgui.utils.Rpc;
>>>>
>>>> rpc.callAsync( "getMenuXml", null );
>>>> rpc.addListener( "completed", function(e)
>>>> {
>>>>         qxgui.reg.MenuXML.getInstance().setMenu( e.getData() );
>>>> });
>>>>
>>>> for some reason the listener doesnt react.
>>>>
>>>> any suggestions?
>>>>
>>>>
>>>> ps: i appreciate the great support in this mailing list!
>>>>
>>>> regards
>>>> Andreas
>>>>
>>>>
>>>> Derrell Lipman wrote:
>>>>> On Wed, May 6, 2009 at 9:24 AM, sNIk <[email protected]> wrote:
>>>>>
>>>>>> hello. at first the code ...
>>>>>>
>>>>>> qx.Class.define("qxgui.reg.MenuXML",
>>>>>> {
>>>>>>    extend: qx.core.Object,
>>>>>>    type: "singleton",
>>>>>>
>>>>>>    construct: function()
>>>>>>    {
>>>>>>        var rpc = new qxgui.utils.Rpc;
>>>>>>
>>>>>>        rpc.callAsync( "getMenuXml", null, function( result )
>>>>>>        {
>>>>>>            qxgui.reg.MenuXML.getInstance().setMenu( result );
>>>>>>        });
>>>>>>    },
>>>>>>
>>>>>>    members:
>>>>>>    {
>>>>>>        // eigenschaften
>>>>>>
>>>>>> //////////////////////////////////////////////////////////////////////// 
>>>>>>
>>>>>>
>>>>>>        __menuxml: null,
>>>>>>
>>>>>>
>>>>>>        // methoden
>>>>>>
>>>>>> //////////////////////////////////////////////////////////////////////// 
>>>>>>
>>>>>>
>>>>>>        setMenu: function( menuxml )
>>>>>>        {
>>>>>>            this.__menuxml = menuxml;
>>>>>>        },
>>>>>>
>>>>>>        getMenu: function()
>>>>>>        {
>>>>>>            return this.__menuxml;
>>>>>>        }
>>>>>>
>>>>>>    }
>>>>>> });
>>>>>>
>>>>>> usage: var menu = qxgui.reg.MenuXML.getInstance().getMenu();
>>>>>>
>>>>>> now back to my problem ... when i run alert( menuxml ) in setMenu, 
>>>>>> i get
>>>>>> the
>>>>>> right output (some xml stuff). actually, the result is saved in the
>>>>>> property
>>>>>> __menuxml, right?
>>>>>>
>>>>>> but alert( menu ) gives me the damn null. any suggestions?
>>>>>>
>>>>> You're missing the main concept that it takes time (for the purpose of
>>>>> this
>>>>> discussion, assume 3 seconds even though that's unreasonably high in 
>>>>> most
>>>>> real scenarios) to issue your remote procedure call, have the backend
>>>>> server
>>>>> process the request and send back the response, and for the client
>>>>> (qooxdoo
>>>>> program) to receive the response and call your listener function which
>>>>> calls
>>>>> setMenu(). Therefore when you call qxgui.reg.MenuXML.getInstance() it
>>>>> *begins* that process and returns. Three seconds later, the response
>>>>> arrives, your listener is called, and therefore the menu property gets
>>>>> set.
>>>>> So what's happening when you just issue this:
>>>>>
>>>>>   var menu = qxgui.reg.MenuXML.getInstance().getMenu();
>>>>>
>>>>> the request has been issued before getMenu() is called but the
>>>>> response
>>>>> has
>>>>> not yet arrived, so the value of the menu property is still null, thus
>>>>> alert(menu) displays null. You are operating in an asynchronous 
>>>>> world now,
>>>>> not a synchronous one. You must organize your program around events, 
>>>>> not
>>>>> in-line code that you expect to block until a result arrives.
>>>>>
>>>>> Hope that helps.
>>>>>
>>>>> Derrell
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>>  
>>>>>
>>>>> 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
>>>>>
>>>>>
>>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>  
>>>
>>> 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
>>>
>>>
>> 
>> 
>> ------------------------------------------------------------------------
>> 
>> ------------------------------------------------------------------------------
>> 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
> 
> 
> ------------------------------------------------------------------------------
> 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/going-crazy-...-%28-callback-again-%29-tp2815007p2826445.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