I'm trying to read a .txt file into my Gadget using RequestBuilder,
but when I call .getText() on the Response, I don't get any actual
text. The goal is to have the string returned by .getText() contain
all the text in that file.
I call:
// Retrieve the file data
getFile("https://sites.google.com/site/urbanahawksband/pbb-gadget-
files/test.txt");
which is defined as:
/**
* Retrieves a file from a server, and copies its text into 'pbb_text'.
*
* @param url : The URL of the file to be retrieved.
*/
public static void getFile(String url) {
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
URL.encode(url));
try {
builder.sendRequest("", new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
pbb_text = "Error on request.";
}
@Override
public void onResponseReceived(Request request, Response
response) {
pbb_text = response.getText();
}
});
} catch (RequestException ex) {
pbb_text = "RequestException thrown and caught.";
}
}
I then try to display 'pbb_text' on a Label in my Gadget, but the text
returned is simply "".
Any ideas would be greatly appreciated.
--
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.