Package com.google.gwt.http.client

Examples of com.google.gwt.http.client.RequestBuilder$Method


      }
    };

    increaseRequestCounter();

    RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url);
    if (requestTimeout > 0)
      builder.setTimeoutMillis(requestTimeout);
    builder.setHeader("Content-Type", "application/json; charset=utf-8");
    String body = new String(encode(request));
    builder.setHeader("Content-Length", Integer.toString(body.length()));
    if (requestCookie != null)
      if (Cookies.getCookie(requestCookie) != null)
        builder.setHeader("X-Cookie", Cookies.getCookie(requestCookie));
    if (username != null)
      builder.setUser(username);
    if (password != null)
      builder.setPassword(password);
    try {
      builder.sendRequest(body, handler);
    } catch (RequestException exception) {
      handler.onError(null, exception);
    }
  }
View Full Code Here


public class HttpRequestXmlLoader implements AsyncXmlLoader {

  @Override
  public void loadResource(final String resourceUrl, final AsyncXmlLoaderCallback callback) {
    String currentResourceUrl = resourceUrl + ((resourceUrl.indexOf("?") == -1) ? ("?ts=" + System.currentTimeMillis()) : ("&ts=" + + System.currentTimeMillis()));
    RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, currentResourceUrl);
    requestBuilder.setCallback(new RequestCallback() {
      public void onError(Request request, Throwable exception) {
        callback.onError(resourceUrl, exception);
      }

      private void onSuccess(Request request, Response response) {
        SVGParserImpl impl = GWT.create(SVGParserImpl.class);
        Element root = impl.parse(response.getText());
        callback.onSuccess(resourceUrl, root);
      }
     
      public void onResponseReceived(Request request, Response response) {
        if (response.getStatusCode() == Response.SC_OK) {
          onSuccess(request, response);
        } else {
          onError(request, null);
        }
      }
    });
    try {
      requestBuilder.send();
    } catch (RequestException e) {
      GWT.log("Cannot fetch " + resourceUrl, e);
    }
  }
View Full Code Here

      callback.onSuccess(cache[index]);
      return;
    }

    // Otherwise, fire an HTTP request.
    RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
    try {
      rb.sendRequest("", new ESRCallback(callback));
    } catch (RequestException e) {
      throw new ResourceException(this,
          "Unable to initiate request for external resource", e);
    }
  }
View Full Code Here

     
      String prefixURL = SEARCH_URL + "/" + ((SuggestBox)event.getSource()).getText();

      // get substring to send
      // Send request to server and catch any errors.
        RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, prefixURL);
        System.out.println("sending to " + prefixURL);
        builder.sendRequest(
            null, new RequestCallback() {
           
            public void onError(Request request, Throwable exception) {
               displayError("Couldn't retrieve JSON");
            }
View Full Code Here

    private void checkIfNameExists() {
      // send the input to the server.
      //sendButton.setEnabled(true);
      final String GET_RECORDS_URL = "existence/search";
      String uRL = GET_RECORDS_URL + "?firstname=" + firstNameSuggestBox.getText() + "&lastname=" + lastNameSuggestBox.getText();
      RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, uRL);
        System.out.println("sending to " + uRL);
      try {
        builder.sendRequest(
          null, new RequestCallback() {
           
            public void onError(Request request, Throwable exception) {
              System.out.println("Error: Couldn't retrieve JSON");
            }
View Full Code Here

  private void sendNamesToServer() {
    // send the input to the server.
    SearchDemo.sendButton.setEnabled(false);
    final String GET_RECORDS_URL = "clientrecord";
    String uRL = GET_RECORDS_URL + "?firstname=" + SearchDemo.firstNameSuggestBox.getText() + "&lastname=" + SearchDemo.lastNameSuggestBox.getText();
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, uRL);
      System.out.println("sending to " + uRL);
    try {
      builder.sendRequest(
        null, new RequestCallback() {
         
                                        public void onError(Request request, Throwable exception) {
                                          System.out.println("Error: Couldn't retrieve JSON");
                                        }
View Full Code Here

      b4.setEnabled(false);
      final String url = "safe";
      String pw = ptb.getText();
      String un = untb.getText();
     
      RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
      builder.setUser(un);
      builder.setPassword(pw);
     
      System.out.println("sending to " + url);
      try {
        builder.sendRequest(
          null, new RequestCallback() {
           
                                          public void onError(Request request, Throwable exception) {
                                            System.out.println("Error: Couldn't send credentials");
                                            System.out.println("Exception is: " + exception);
View Full Code Here

    /**
     * Send the Person XML to the server and wait for a response.
     * @param sendButton
     */
    private void sendXMLToServer() {
      RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, "./client/add");
      rb.setHeader("Content-Type", "application/xml");
      try {
        rb.sendRequest(long_xml,   
            new RequestCallback() {
         
            public void onError(Request request, Throwable exception) {
              System.out.println("Error: Couldn't retrieve Response");
            }
View Full Code Here

    /**
     * Send the search JSON to the server and wait for a response.
     * @param sendButton
     */
    private void sendJSONToServer() {
      RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, "./client/search");
      rb.setHeader("Content-Type", "application/json");
      try {
        rb.sendRequest(json,   
            new RequestCallback() {
         
            public void onError(Request request, Throwable exception) {
              System.out.println("Error: Couldn't retrieve Response");
            }
View Full Code Here

    /**
     * Send the Person XML to the server and wait for a response.
     * @param sendButton
     */
    private void sendXMLToServer() {
      RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, "./client/update?id=1");
      rb.setHeader("Content-Type", "application/xml");
      try {
        rb.sendRequest(long_xml,   
            new RequestCallback() {
         
            public void onError(Request request, Throwable exception) {
              System.out.println("Error: Couldn't retrieve Response");
            }
View Full Code Here

TOP

Related Classes of com.google.gwt.http.client.RequestBuilder$Method

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.