I was not aware of the "call" method. Thanks!
-deech

On Thu, Oct 8, 2009 at 4:11 AM, Matthew Gregory
<[email protected]<matthew%[email protected]>
> wrote:

> Hi Again,
> You need to change context.func(resp); to func.call(context, reps);
> This has nothing to with it being a static class the orriginal code
> won't work.
>
> Also in your calling code you do not have any closures so you don't need
> to sore 'this' in 'that' simply do this:
>
> var callback = Utility.makeCallBack(this.setAndPrintResponse, this);
>
> I can't say for sure without looking at the rest of your code put your
> makeCallBack function is the same as qx.lang.Function.bind
>
> aditya siram wrote:
> > Thanks for the reply Matt and Axel - those solutions worked. However I
> > do have a further question.
> >
> > I wanted to take that function that creates a callback and move it to a
> > static utility class.
> >
> > class Utility:
> >    type : 'static'
> >    members :
> >         makeCallback(func, context) {
> >            var _func = function (resp) {context.func(resp);};
> >            return _func;
> >         }
> >
> > And then pass it a function from Class A like :
> > var that = this;
> > car callback = Utility.makeCallBack(this.setAndPrintResponse, that);
> >
> > But this doesn't work - Firebug complains that 'context.func' is not a
> > function.
> >
> > What is the difference between this code being in the 'ask' function as
> > below, and in a static class?
> >
> > -deech
> >
> > On Fri, Oct 2, 2009 at 7:14 AM, Matthew Gregory
> > <[email protected] <matthew%[email protected]> <mailto:
> matthew%[email protected] <matthew%[email protected]>>> wrote:
> >
> >     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&reg; 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&#45;12, 2009.
> >     Register now&#33;
> >      > http://p.sf.net/sfu/devconf
> >
> >
> >
> ------------------------------------------------------------------------------
> >     Come build with us! The BlackBerry&reg; 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&#45;12, 2009. Register
> >     now&#33;
> >     http://p.sf.net/sfu/devconf
> >     _______________________________________________
> >     qooxdoo-devel mailing list
> >     [email protected]
> >     <mailto:[email protected]>
> >     https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> >
> ------------------------------------------------------------------------------
> > Come build with us! The BlackBerry(R) 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/devconference
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > qooxdoo-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) 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/devconference
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) 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/devconference
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to