As Ian said, the requestBuilder.sendRequest method is asynchronous, that is, the "send" call will return immediately (without waiting for a server response) and the next statement in your application will be executed, in this case the "System.out.println(temp); //HERE ALWAYS NULL". Later on the response from the server will be received and your onResponseReceived method will be called at which time the temp variable will be initialized.
What you have to remember is that Javascript is single threaded and therefore you can't block waiting for a response. You'll need to reorganize your code to handle this, usually by defining and passing in your own callback to XmlFile which will be called back when the XML is received. On Oct 17, 1:14 pm, Ian Bambury <[email protected]> wrote: > Yes. > Use it in the onResponseReceived. > > You are trying to use it *before* you have received a response. It's like > buying something on-line and trying to use it the moment you have ordered it > and wondering why you can't find it - you have to wait until it turns up :-) > > Ian > > http://examples.roughian.com > > 2009/10/17 Tomek <[email protected]> > > > > > > > Anyone? > > I know that it's because GWT is asynchronous but is there a way to > > save my xml file to a variable? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
