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