Hi everyone,
I am testing out the HTTP system in GWT to get some html from a site.
Here is my code. I simply cut out some stuff from the code that GWT
generated.

package com.vance.test.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.*;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.http.client.*;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class TestFindContent implements EntryPoint, RequestCallback,
com.google.gwt.event.dom.client.ClickHandler {
        private boolean done=false;
        private HTML html;
        private Button button = new Button("Hello:");
        private RequestBuilder builder;
        private com.google.gwt.user.client.ui.TextArea textarea;
        private com.google.gwt.user.client.ui.TextBox textbox;
        private com.google.gwt.user.client.ui.HorizontalPanel panel;
        /**
         * The message displayed to the user when the server cannot be
reached or
         * returns an error.
         */
        private static final String SERVER_ERROR = "An error occurred while "
                        + "attempting to contact the server. Please check your 
network "
                        + "connection and try again.";

        /**
         * Create a remote service proxy to talk to the server-side Greeting
service.
         */
        private final GreetingServiceAsync greetingService = GWT
                        .create(GreetingService.class);

        /**
         * This is the entry point method.
         */
        public void onModuleLoad() {
                html = new HTML();
                textbox = new com.google.gwt.user.client.ui.TextBox();
                textbox.setSize("40em", "3ex");
                textarea = new com.google.gwt.user.client.ui.TextArea();
                button = new Button();
                button.setText("Send Request");
                panel = new com.google.gwt.user.client.ui.HorizontalPanel();
                panel.add(textbox);
                panel.add(button);
                RootPanel.get().add(panel);
                button.addClickHandler(this);
        }

        public void onError(Request request,java.lang.Throwable throwable ){
                textarea.setText("Error=="+throwable.getMessage());
                RootPanel.get().add(textarea);
        }

        public void onResponseReceived(Request request, Response response){
                textbox.setText("Response received!!");
                html.setHTML(response.getText());
                RootPanel.get().add(html);
                RootPanel.get().add(textarea);
                textarea.setText("Code=="+response.getStatusCode()+"
Status=="+response.getStatusText());;
        }

        public void onClick(com.google.gwt.event.dom.client.ClickEvent event)
{
                try{
                        builder = new 
RequestBuilder(RequestBuilder.GET,textbox.getText());
                        builder.sendRequest("", this);
                }catch(Exception e){

                }
        }
}



For some reason, I always get a response code of 0, and the status
code text is OK. Also, I'm not getting any firewall warnings from the
OS, Linux or Windows 7. Is this the correct way to request a page from
a server?
Thanks,
Vance

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