Thank you Jason for your help. That was a bad mistake. Anywhere I used
other code and it worked. The problem i have is that I have conficting
results. One statement tells me I have the data and the other says the
same data is null. Worse enough, if I call the same statement twice i
get different results. for example, passing the same string to
window.alert twice brings null and some correct string. I want to
later plot the received data using canvas. Here is the code.
package com.daq.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.http.client.*;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.user.client.Window;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class thesis implements EntryPoint {
public static final int STATUS_CODE_OK = 200;
static String recvd_data;
private VerticalPanel mainPanel = new VerticalPanel();
DialogBox diagbox = new DialogBox();
Button button = new Button("Click Me");
Label testLabel = new Label();
static String my_data;
//String[] formated_data;
public static String doGet(String url) {
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
url);
try {
Request response = builder.sendRequest(null, new
RequestCallback() {
public void onError(Request request, Throwable exception) {
recvd_data = "Unable to reach the server";
Window.alert(recvd_data);
//responseText(recvd_data);
}
public void onResponseReceived(Request request, Response
response) {
// Code omitted for clarity
//String recvd_data;
if(response.getStatusCode() == STATUS_CODE_OK)
{
recvd_data = response.getText();
}
else
recvd_data = response.getStatusText();
recvd_data = recvd_data.trim();
//responseText(recvd_data);
//Window.alert(recvd_data);
}
});
} catch (RequestException e) {
recvd_data = "Unresolved Error";
//responseText(recvd_data);
Window.alert(recvd_data);
return recvd_data;
}
return recvd_data;
}
/**********************************************************
* get the string received from the http response
*********************************************************/
public static void responseText(String resp_text)
{
my_data = resp_text;
//Window.alert(my_data);
}
public void onModuleLoad() {
recvd_data = doGet("sw.csv"); //it seems that null is
returned in
this case
/*line 82 *///Window.alert(recvd_data);
/*if u uncomment line 82, it will print null on a window and the
correct text will display by line 93
* however when u leave it commented, line 93 has no effect */
mainPanel.setTitle("Main Panel");
mainPanel.setBorderWidth(300);
mainPanel.add(button);
//mainPanel.setVisible(true);
//formated_data = my_data.split(",");
/* line 93*/ testLabel.setText(recvd_data);
diagbox.setTitle("Dialog Box");
diagbox.setWidth("100%");
diagbox.setHeight("20%");
diagbox.setText(recvd_data);
RootPanel.get().add(testLabel);
//RootPanel.get().add(diagbox);
//RootPanel.get().add(mainPanel);
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---