|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
RE: AW: Getting data from a callbackDavid,
DWR makes asynchronous calls. Remote.doSomething(callMetaData); alert(someObject.privateVar); // "Private variable from hell" which I want to be Hello someObject.privateVar is going to be "Private variable from hell" until the remote call has been executed and returned, thus the callback function. Because this call is asynchronous my guess is that your alert (the one following your remote call) is being displayed before the call has completed. Original Message: ----------------- From: David.Luecke@... Date: Wed, 23 Apr 2008 18:48:35 +0200 To: users@... Subject: AW: [dwr-user] Getting data from a callback Hi David. Thanks for your reply. I read the page a few times before because I thought it a scoping issue, too (in Java you can overwrite member variables with local variables, too). I now switched to 3.0M1 and got the example working but it's the same issue again (probably I'm doing something terribly wrong...): (function() { someObject = {}; someObject.privateVar = "Private variable from hell"; someObject.callbackFunction = function(dataFromServer) { this.privateVar = "Hello world"; alert(this.privateVar); // "Hello world" } })(); var callMetaData = { callback: someObject.callbackFunction, scope: someObject }; Remote.doSomething(callMetaData); alert(someObject.privateVar); // "Private variable from hell" which I want to be "Hello world" oder dataFromServer or whatever Do I have to use another scope? Greetings David -----Ursprüngliche Nachricht----- Von: david@... [mailto:david@...] Gesendet: Mittwoch, 23. April 2008 17:22 An: users@... Betreff: RE: [dwr-user] Getting data from a callback This is a scoping issue. Please read this: http://getahead.org/dwr/browser/extradata Original Message: ----------------- From: David.Luecke@... Date: Wed, 23 Apr 2008 17:14:09 +0200 To: users@... Subject: [dwr-user] Getting data from a callback Hi. I'm quite new to DWR and I really like it, but I think I have a problem with the JavaScript part ;) How can I get the return values of a callback into JavaScript "global" variables? I can read variables in the callback function but cannot modify them. E.g.: { this.test = "Hello"; var obj = this; var callbackfunc = function(arg) { alert(obj.test); // alerts "Hello" obj.test = "Test"; // or obj.test = arg; alert(obj.test); // alerts "Test" } Remote.doSomething(callbackfunc); alert(obj.test); // alerts Hello } Will always alert "Hello" and I don't understand why or how I could get at the return values from the outside at all. Thanks a lot in advance Regards David -------------------------------------------------------------------- mail2web.com - Enhanced email for the mobile individual based on Microsoft® Exchange - http://link.mail2web.com/Personal/EnhancedEmail --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... -------------------------------------------------------------------- mail2web - Check your email from the web at http://link.mail2web.com/mail2web --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
AW: AW: Getting data from a callbackHi David.
Thanks you're right. I assumed something like that before but placed the setTimeout in the wrong order. var callMetaData = { callback: someObject.callbackFunction, scope: someObject, timeout: 1000 }; Remote.getReasons(callMetaData); var nothing = function() { alert(someObject.privateVar); } window.setTimeout(nothing, 1000); Works. I found no other way to determine if my callback has returned but this should work as a start since I load all data only once. Thanks again. David -----Ursprüngliche Nachricht----- Von: david@... [mailto:david@...] Gesendet: Mittwoch, 23. April 2008 19:15 An: users@... Betreff: RE: AW: [dwr-user] Getting data from a callback David, DWR makes asynchronous calls. Remote.doSomething(callMetaData); alert(someObject.privateVar); // "Private variable from hell" which I want to be Hello someObject.privateVar is going to be "Private variable from hell" until the remote call has been executed and returned, thus the callback function. Because this call is asynchronous my guess is that your alert (the one following your remote call) is being displayed before the call has completed. Original Message: ----------------- From: David.Luecke@... Date: Wed, 23 Apr 2008 18:48:35 +0200 To: users@... Subject: AW: [dwr-user] Getting data from a callback Hi David. Thanks for your reply. I read the page a few times before because I thought it a scoping issue, too (in Java you can overwrite member variables with local variables, too). I now switched to 3.0M1 and got the example working but it's the same issue again (probably I'm doing something terribly wrong...): (function() { someObject = {}; someObject.privateVar = "Private variable from hell"; someObject.callbackFunction = function(dataFromServer) { this.privateVar = "Hello world"; alert(this.privateVar); // "Hello world" } })(); var callMetaData = { callback: someObject.callbackFunction, scope: someObject }; Remote.doSomething(callMetaData); alert(someObject.privateVar); // "Private variable from hell" which I want to be "Hello world" oder dataFromServer or whatever Do I have to use another scope? Greetings David -----Ursprüngliche Nachricht----- Von: david@... [mailto:david@...] Gesendet: Mittwoch, 23. April 2008 17:22 An: users@... Betreff: RE: [dwr-user] Getting data from a callback This is a scoping issue. Please read this: http://getahead.org/dwr/browser/extradata Original Message: ----------------- From: David.Luecke@... Date: Wed, 23 Apr 2008 17:14:09 +0200 To: users@... Subject: [dwr-user] Getting data from a callback Hi. I'm quite new to DWR and I really like it, but I think I have a problem with the JavaScript part ;) How can I get the return values of a callback into JavaScript "global" variables? I can read variables in the callback function but cannot modify them. E.g.: { this.test = "Hello"; var obj = this; var callbackfunc = function(arg) { alert(obj.test); // alerts "Hello" obj.test = "Test"; // or obj.test = arg; alert(obj.test); // alerts "Test" } Remote.doSomething(callbackfunc); alert(obj.test); // alerts Hello } Will always alert "Hello" and I don't understand why or how I could get at the return values from the outside at all. Thanks a lot in advance Regards David -------------------------------------------------------------------- mail2web.com - Enhanced email for the mobile individual based on Microsoft® Exchange - http://link.mail2web.com/Personal/EnhancedEmail --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... -------------------------------------------------------------------- mail2web - Check your email from the web at http://link.mail2web.com/mail2web --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: AW: AW: Getting data from a callbackInstead of the timeout approach why don't you add a function call in
your callback to perform the logic that is required? David.Luecke@... wrote: > Hi David. > > Thanks you're right. I assumed something like that before but placed the setTimeout in the wrong order. > > var callMetaData = { > callback: someObject.callbackFunction, > scope: someObject, > timeout: 1000 > }; > > Remote.getReasons(callMetaData); > > var nothing = function() { alert(someObject.privateVar); } > window.setTimeout(nothing, 1000); > > > Works. I found no other way to determine if my callback has returned but this should work as a start since I load all data only once. > > Thanks again. > David > > -----Ursprüngliche Nachricht----- > Von: david@... [mailto:david@...] > Gesendet: Mittwoch, 23. April 2008 19:15 > An: users@... > Betreff: RE: AW: [dwr-user] Getting data from a callback > > David, > DWR makes asynchronous calls. > > Remote.doSomething(callMetaData); > alert(someObject.privateVar); // "Private variable from hell" which I want > to be Hello > > someObject.privateVar is going to be "Private variable from hell" until the > remote call has been executed and returned, thus the callback function. > Because this call is asynchronous my guess is that your alert (the one > following your remote call) is being displayed before the call has > completed. > > > Original Message: > ----------------- > From: David.Luecke@... > Date: Wed, 23 Apr 2008 18:48:35 +0200 > To: users@... > Subject: AW: [dwr-user] Getting data from a callback > > > Hi David. > > Thanks for your reply. I read the page a few times before because I thought > it a scoping issue, too (in Java you can overwrite member variables with > local variables, too). > I now switched to 3.0M1 and got the example working but it's the same issue > again (probably I'm doing something terribly wrong...): > > (function() { > someObject = {}; > someObject.privateVar = "Private variable from hell"; > > someObject.callbackFunction = function(dataFromServer) > { > this.privateVar = "Hello world"; > alert(this.privateVar); // "Hello world" > } > })(); > > var callMetaData = { > callback: someObject.callbackFunction, > scope: someObject > }; > > Remote.doSomething(callMetaData); > > alert(someObject.privateVar); // "Private variable from hell" which I want > to be "Hello world" oder dataFromServer or whatever > > > Do I have to use another scope? > > Greetings > David > > -----Ursprüngliche Nachricht----- > Von: david@... [mailto:david@...] > Gesendet: Mittwoch, 23. April 2008 17:22 > An: users@... > Betreff: RE: [dwr-user] Getting data from a callback > > This is a scoping issue. Please read this: > http://getahead.org/dwr/browser/extradata > > > Original Message: > ----------------- > From: David.Luecke@... > Date: Wed, 23 Apr 2008 17:14:09 +0200 > To: users@... > Subject: [dwr-user] Getting data from a callback > > > Hi. > > > > I'm quite new to DWR and I really like it, but I think I have a problem > with the JavaScript part ;) > > How can I get the return values of a callback into JavaScript "global" > variables? > > I can read variables in the callback function but cannot modify them. > > > > E.g.: > > > > { > > this.test = "Hello"; > > var obj = this; > > > > var callbackfunc = function(arg) > > { > > alert(obj.test); // alerts "Hello" > > obj.test = "Test"; > > // or obj.test = arg; > > alert(obj.test); // alerts "Test" > > } > > > > Remote.doSomething(callbackfunc); > > > > alert(obj.test); // alerts Hello > > } > > > > > > Will always alert "Hello" and I don't understand why > > or how I could get at the return values from the outside at all. > > > > Thanks a lot in advance > > Regards > > David > > > > -------------------------------------------------------------------- > mail2web.com - Enhanced email for the mobile individual based on Microsoft® > Exchange - http://link.mail2web.com/Personal/EnhancedEmail > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > > -------------------------------------------------------------------- > mail2web - Check your email from the web at > http://link.mail2web.com/mail2web > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
AW: AW: AW: Getting data from a callbackYes I realized that one second after I clicked the send button ;)
This is an approach I can live with var goOn = function() { } // Place the getReasons call var callMetaData = { callback: function(dataFromServer) { goOn(); // Callback callback }, timeout: 1000 // and so on }; Remote.doSomething(callMetaData); Thanks a lot again. David -----Ursprüngliche Nachricht----- Von: David Marginian [mailto:david@...] Gesendet: Donnerstag, 24. April 2008 08:40 An: users@... Betreff: Re: AW: AW: [dwr-user] Getting data from a callback Instead of the timeout approach why don't you add a function call in your callback to perform the logic that is required? David.Luecke@... wrote: > Hi David. > > Thanks you're right. I assumed something like that before but placed the setTimeout in the wrong order. > > var callMetaData = { > callback: someObject.callbackFunction, > scope: someObject, > timeout: 1000 > }; > > Remote.getReasons(callMetaData); > > var nothing = function() { alert(someObject.privateVar); } > window.setTimeout(nothing, 1000); > > > Works. I found no other way to determine if my callback has returned but this should work as a start since I load all data only once. > > Thanks again. > David > > -----Ursprüngliche Nachricht----- > Von: david@... [mailto:david@...] > Gesendet: Mittwoch, 23. April 2008 19:15 > An: users@... > Betreff: RE: AW: [dwr-user] Getting data from a callback > > David, > DWR makes asynchronous calls. > > Remote.doSomething(callMetaData); > alert(someObject.privateVar); // "Private variable from hell" which I want > to be Hello > > someObject.privateVar is going to be "Private variable from hell" until the > remote call has been executed and returned, thus the callback function. > Because this call is asynchronous my guess is that your alert (the one > following your remote call) is being displayed before the call has > completed. > > > Original Message: > ----------------- > From: David.Luecke@... > Date: Wed, 23 Apr 2008 18:48:35 +0200 > To: users@... > Subject: AW: [dwr-user] Getting data from a callback > > > Hi David. > > Thanks for your reply. I read the page a few times before because I thought > it a scoping issue, too (in Java you can overwrite member variables with > local variables, too). > I now switched to 3.0M1 and got the example working but it's the same issue > again (probably I'm doing something terribly wrong...): > > (function() { > someObject = {}; > someObject.privateVar = "Private variable from hell"; > > someObject.callbackFunction = function(dataFromServer) > { > this.privateVar = "Hello world"; > alert(this.privateVar); // "Hello world" > } > })(); > > var callMetaData = { > callback: someObject.callbackFunction, > scope: someObject > }; > > Remote.doSomething(callMetaData); > > alert(someObject.privateVar); // "Private variable from hell" which I want > to be "Hello world" oder dataFromServer or whatever > > > Do I have to use another scope? > > Greetings > David > > -----Ursprüngliche Nachricht----- > Von: david@... [mailto:david@...] > Gesendet: Mittwoch, 23. April 2008 17:22 > An: users@... > Betreff: RE: [dwr-user] Getting data from a callback > > This is a scoping issue. Please read this: > http://getahead.org/dwr/browser/extradata > > > Original Message: > ----------------- > From: David.Luecke@... > Date: Wed, 23 Apr 2008 17:14:09 +0200 > To: users@... > Subject: [dwr-user] Getting data from a callback > > > Hi. > > > > I'm quite new to DWR and I really like it, but I think I have a problem > with the JavaScript part ;) > > How can I get the return values of a callback into JavaScript "global" > variables? > > I can read variables in the callback function but cannot modify them. > > > > E.g.: > > > > { > > this.test = "Hello"; > > var obj = this; > > > > var callbackfunc = function(arg) > > { > > alert(obj.test); // alerts "Hello" > > obj.test = "Test"; > > // or obj.test = arg; > > alert(obj.test); // alerts "Test" > > } > > > > Remote.doSomething(callbackfunc); > > > > alert(obj.test); // alerts Hello > > } > > > > > > Will always alert "Hello" and I don't understand why > > or how I could get at the return values from the outside at all. > > > > Thanks a lot in advance > > Regards > > David > > > > -------------------------------------------------------------------- > mail2web.com - Enhanced email for the mobile individual based on Microsoft® > Exchange - http://link.mail2web.com/Personal/EnhancedEmail > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > > -------------------------------------------------------------------- > mail2web - Check your email from the web at > http://link.mail2web.com/mail2web > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: AW: AW: AW: Getting data from a callbackGreat. Much better than the timeout.
David.Luecke@... wrote: > Yes I realized that one second after I clicked the send button ;) > > This is an approach I can live with > > var goOn = function() > { > > } > > // Place the getReasons call > var callMetaData = { > callback: function(dataFromServer) > { > goOn(); // Callback callback > }, > timeout: 1000 > // and so on > }; > > Remote.doSomething(callMetaData); > > Thanks a lot again. > > David > > -----Ursprüngliche Nachricht----- > Von: David Marginian [mailto:david@...] > Gesendet: Donnerstag, 24. April 2008 08:40 > An: users@... > Betreff: Re: AW: AW: [dwr-user] Getting data from a callback > > Instead of the timeout approach why don't you add a function call in > your callback to perform the logic that is required? > > David.Luecke@... wrote: > >> Hi David. >> >> Thanks you're right. I assumed something like that before but placed the setTimeout in the wrong order. >> >> var callMetaData = { >> callback: someObject.callbackFunction, >> scope: someObject, >> timeout: 1000 >> }; >> >> Remote.getReasons(callMetaData); >> >> var nothing = function() { alert(someObject.privateVar); } >> window.setTimeout(nothing, 1000); >> >> >> Works. I found no other way to determine if my callback has returned but this should work as a start since I load all data only once. >> >> Thanks again. >> David >> >> -----Ursprüngliche Nachricht----- >> Von: david@... [mailto:david@...] >> Gesendet: Mittwoch, 23. April 2008 19:15 >> An: users@... >> Betreff: RE: AW: [dwr-user] Getting data from a callback >> >> David, >> DWR makes asynchronous calls. >> >> Remote.doSomething(callMetaData); >> alert(someObject.privateVar); // "Private variable from hell" which I want >> to be Hello >> >> someObject.privateVar is going to be "Private variable from hell" until the >> remote call has been executed and returned, thus the callback function. >> Because this call is asynchronous my guess is that your alert (the one >> following your remote call) is being displayed before the call has >> completed. >> >> >> Original Message: >> ----------------- >> From: David.Luecke@... >> Date: Wed, 23 Apr 2008 18:48:35 +0200 >> To: users@... >> Subject: AW: [dwr-user] Getting data from a callback >> >> >> Hi David. >> >> Thanks for your reply. I read the page a few times before because I thought >> it a scoping issue, too (in Java you can overwrite member variables with >> local variables, too). >> I now switched to 3.0M1 and got the example working but it's the same issue >> again (probably I'm doing something terribly wrong...): >> >> (function() { >> someObject = {}; >> someObject.privateVar = "Private variable from hell"; >> >> someObject.callbackFunction = function(dataFromServer) >> { >> this.privateVar = "Hello world"; >> alert(this.privateVar); // "Hello world" >> } >> })(); >> >> var callMetaData = { >> callback: someObject.callbackFunction, >> scope: someObject >> }; >> >> Remote.doSomething(callMetaData); >> >> alert(someObject.privateVar); // "Private variable from hell" which I want >> to be "Hello world" oder dataFromServer or whatever >> >> >> Do I have to use another scope? >> >> Greetings >> David >> >> -----Ursprüngliche Nachricht----- >> Von: david@... [mailto:david@...] >> Gesendet: Mittwoch, 23. April 2008 17:22 >> An: users@... >> Betreff: RE: [dwr-user] Getting data from a callback >> >> This is a scoping issue. Please read this: >> http://getahead.org/dwr/browser/extradata >> >> >> Original Message: >> ----------------- >> From: David.Luecke@... >> Date: Wed, 23 Apr 2008 17:14:09 +0200 >> To: users@... >> Subject: [dwr-user] Getting data from a callback >> >> >> Hi. >> >> >> >> I'm quite new to DWR and I really like it, but I think I have a problem >> with the JavaScript part ;) >> >> How can I get the return values of a callback into JavaScript "global" >> variables? >> >> I can read variables in the callback function but cannot modify them. >> >> >> >> E.g.: >> >> >> >> { >> >> this.test = "Hello"; >> >> var obj = this; >> >> >> >> var callbackfunc = function(arg) >> >> { >> >> alert(obj.test); // alerts "Hello" >> >> obj.test = "Test"; >> >> // or obj.test = arg; >> >> alert(obj.test); // alerts "Test" >> >> } >> >> >> >> Remote.doSomething(callbackfunc); >> >> >> >> alert(obj.test); // alerts Hello >> >> } >> >> >> >> >> >> Will always alert "Hello" and I don't understand why >> >> or how I could get at the return values from the outside at all. >> >> >> >> Thanks a lot in advance >> >> Regards >> >> David >> >> >> >> -------------------------------------------------------------------- >> mail2web.com - Enhanced email for the mobile individual based on Microsoft® >> Exchange - http://link.mail2web.com/Personal/EnhancedEmail >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@... >> For additional commands, e-mail: users-help@... >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@... >> For additional commands, e-mail: users-help@... >> >> >> >> -------------------------------------------------------------------- >> mail2web - Check your email from the web at >> http://link.mail2web.com/mail2web >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@... >> For additional commands, e-mail: users-help@... >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@... >> For additional commands, e-mail: users-help@... >> >> >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free Forum Powered by Nabble | Forum Help |