Axel's suggestion will work, but you need to pass the parameter
class A:
members :
response : null,
ask : function () {
var that = this;
var callback = function(resp) {
that.setAndPrintResponse(resp);
};
util.makeServerRequest(callback)
},
setAndPrintResponse : function (resp) {
this.debug(resp);
this.response = resp;
}
Also have a look at the api for qx.lang.Function.bind. You can think of
it as returning a function pointer where the context is bound to the
object that you passed into the bind function.
HTH,
Matt
Axel wrote:
> Hi aditya,
>
>> Suppose I have the following class A (pseudo-code) :
>> class A:
>> members :
>> response : null,
>> ask : function () { util,makeServerRequest
>> (this.setAndPrintResponse)},
>> setAndPrintResponse : function (resp) {
>> this.debug(resp);
>> this.response = resp;
>> }
>>
>> The "ask" function sends the server a request asynchronously and when
>> the reply is received, prints it to the console and updates the instance
>> variable "response".
>>
>> Unfortunately this doesn't work, because the makeServerRequest is part
>> of a static class and looks like this:
>
> I would try this:
>
> class A:
> members :
> response : null,
> ask : function () {
> var that = this;
> var callback = function() {
> that.setAndPrintResponse();
> };
> util.makeServerRequest(callback)
> },
> setAndPrintResponse : function (resp) {
> this.debug(resp);
> this.response = resp;
> }
>
> see also
> http://qooxdoo.org/documentation/0.8/snippets#problems_with_this_in_event_handlers.
>
> Cheers,
> Axel
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel