Hello,
I am a newbie with GWT so please bear with me. I would like to write
some code that fetches some HTTP file. I have read the tutorials but
they do not quite answer my question.
private void readFile(String url)
{
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
URL.encode(url));
System.out.println("fetching...");
try
{
Request request = builder.sendRequest(null, new RequestCallback()
{
public void onError(Request request, Throwable exception)
{
// Couldn't connect to server (could be timeout, SOP
violation, etc.)
}
public void onResponseReceived(Request request, Response
response)
{
System.out.println("response received...");
if (200 == response.getStatusCode())
{
PrintOut(response.getText());
}
else
{
// response.getStatusText()
}
}
});
}
catch (RequestException e)
{
System.out.println("exception..." + e);
// Couldn't connect to server
}
}
public void PrintOut(String msg)
{
System.out.println(msg);
}
public boolean isInputDataValid()
{
PrintOut("Step 1");
readFile("http://localhost:8888/com.bruguier.dbquiz/dbquiz.html");
PrintOut("Step 2");
return true;
}
OK, here's my code. It does something but not quite what I want. The
entry point is the function isInputDataValid(). My problem is that it
prints "Step 1", then "Step 2", then the content of the HTML page. I
guess the fetching is done in another thread. That is not what I want,
since I would like to return a specific boolean depending on the
content of my page.
I guess I could write the code inside the function PrintOut() but that
is not so good. I am planning to fetch several pages and I would have
to replicate the code several times. I could also use a mutex system,
but that I haven't been able to find. Or maybe there's a ready example
using another approach but I couldn't find it.
Please point me toward the right information. I hope I was clear.
Thanks,
Tony
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---