Re: GWT HTTP GET function

2010-06-12 Thread Sky
That won't be very helpful either. The issue is that the call is
happening asynchronously and you have no idea when it's going to come
back with the server response. The idea is that your
onResponseReceived() method calls a some other method, passing the
response. So whatever object needs the response should have a public
method that is called in the onResponseReceived() method.

Make sense?

On Jun 11, 1:43 pm, Jeff Chimene jchim...@gmail.com wrote:
 On 06/10/2010 08:55 AM, Andy wrote:





  public void doGet(String myurl) {

          myurl = URL.encode(myurl);

          RequestBuilder builder = new
  RequestBuilder(RequestBuilder.GET, myurl );

          try {
            Request request = builder.sendRequest(null, new
  RequestCallback() {
              public void onError(Request request, Throwable exception)
  {
                     Window.alert(ERROR. Could not connect to server.);
              }

              public void onResponseReceived(Request request, Response
  response) {
                if (200 == response.getStatusCode()) {
                      String ServerResponse = response.getText();

                } else {
                       Window.alert(ERROR. Errorcode:  +
  response.getStatusCode());
                }
              }
            });

  How can i make this function return SereverResponce variable?

 You can't. It's a void function. Stash the response in a private
 variable and define a getter for that 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 google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: GWT HTTP GET function

2010-06-11 Thread Jeff Chimene
On 06/10/2010 08:55 AM, Andy wrote:
 public void doGet(String myurl) {
 
 myurl = URL.encode(myurl);
 
 RequestBuilder builder = new
 RequestBuilder(RequestBuilder.GET, myurl );
 
 try {
   Request request = builder.sendRequest(null, new
 RequestCallback() {
 public void onError(Request request, Throwable exception)
 {
   Window.alert(ERROR. Could not connect to server.);
 }
 
 public void onResponseReceived(Request request, Response
 response) {
   if (200 == response.getStatusCode()) {
String ServerResponse = response.getText();
 
   } else {
 Window.alert(ERROR. Errorcode:  +
 response.getStatusCode());
   }
 }
   });
 
 How can i make this function return SereverResponce variable?

You can't. It's a void function. Stash the response in a private
variable and define a getter for that 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 google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.