Hello guys,

I'm writing my first project in GWT and I've got the following
problem:

I want to load XML file and save it to a local String variable.

public class XmlFile  {


        String temp;

        public void greetServer() {

        RequestBuilder requestBuilder = new RequestBuilder
(RequestBuilder.GET,   "Test.gwt.xml");


        try {
                requestBuilder.sendRequest(null,new RequestCallback() {

                        @Override
                        public void onResponseReceived(Request request, 
Response response)
{

                                if (response.getStatusCode()==200)
                                {
                                        temp=response.getText();
                                        System.out.println(temp); //HERE OK
                                }

                        }

                        @Override
                        public void onError(Request request, Throwable 
exception) {
                                Window.alert(exception.getMessage().toString());
                        }

                });
        } catch (Exception ex) {
                Window.alert(ex.getMessage().toString());
        }

}
System.out.println(temp); //HERE ALWAYS NULL

}

I have to save loaded file to "temp" variable because I have to do
some other things with it in other classes. If I do it this way my
"temp" varaible is always null outside "onResponseReceived" function.
I've searched the Internet and found that it's because requestbuilder
is asynchronous and I should "make callback of this function". How can
I do that?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to