Examples of XMLHttpRequest


Examples of com.aicontest.visualizer.js.dom.XMLHttpRequest

      IllegalAccessException, IOException {
    WebWrapper ww = new WebWrapper(getJavaScriptPath());
    ww.loadProgram(getProgram());
    ww.runProgram();
    URI uri = replayStringToUri(replaySource);
    XMLHttpRequest xhr = new XMLHttpRequest();
    xhr.open("GET", uri.toString());
    try {
      xhr.send();
    } catch (IOException e) {
      System.err.println("Could not load " + replaySource + ": " + e);
      System.exit(1);
    }
    String replayStr = xhr.getResponseText();
    ScriptableObject replay = ww.construct("Replay",
        new Object[] { replayStr });
    ScriptableObject meta = (ScriptableObject) replay.get("meta", replay);
    NativeArray playernames = (NativeArray) meta.get("playernames", meta);
    int userIndex = playernames.indexOf(botInput.getPlayer());
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest

        name = name.toLowerCase();
        return name.matches("msxml\\d*\\.xsltemplate.*");
    }

    private static Scriptable buildXMLHttpRequest() {
        final SimpleScriptable scriptable = new XMLHttpRequest(false);

        // Don't forget to update XMLHttpRequest.ALL_PROPERTIES_

        // the properties
        addProperty(scriptable, "onreadystatechange", true, true);
View Full Code Here

Examples of com.google.code.apis.rest.client.GUI.XmlHttpRequest

            break;
          }
        }
        CodeGenerator codeGenerator = new CodeGenerator(Analyzer.application);
        String code = codeGenerator.generate(CodeGenerator.dogfood_php5);       
        new XmlHttpRequest(code, SettingsDialog.pathToDiscoverer);       
      }
    });
    autoDiscoverPanel.add(autoDiscoverButton);
    applicationPanel.add(autoDiscoverPanel);
   
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

   * @throws NullPointerException if request data has not been set
   * @throws NullPointerException if a request callback has not been set
   */
  private Request doSend(String requestData, final RequestCallback callback)
      throws RequestException {
    XMLHttpRequest xmlHttpRequest = XMLHttpRequest.create();

    try {
      if (user != null && password != null) {
        xmlHttpRequest.open(httpMethod, url, user, password);
      } else if (user != null) {
        xmlHttpRequest.open(httpMethod, url, user);
      } else {
        xmlHttpRequest.open(httpMethod, url);
      }
    } catch (JavaScriptException e) {
      RequestPermissionException requestPermissionException = new RequestPermissionException(
          url);
      requestPermissionException.initCause(new RequestException(e.getMessage()));
      throw requestPermissionException;
    }

    setHeaders(xmlHttpRequest);

    final Request request = new Request(xmlHttpRequest, timeoutMillis, callback);

    // Must set the onreadystatechange handler before calling send().
    xmlHttpRequest.setOnReadyStateChange(new ReadyStateChangeHandler() {
      public void onReadyStateChange(XMLHttpRequest xhr) {
        if (xhr.getReadyState() == XMLHttpRequest.DONE) {
          xhr.clearOnReadyStateChange();
          request.fireOnResponseReceived(callback);
        }
      }
    });

    try {
      xmlHttpRequest.send(requestData);
    } catch (JavaScriptException e) {
      throw new RequestException(e.getMessage());
    }

    return request;
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

     *
     * Setting the onreadystatechange handler to null gives us the correct
     * behavior in Mozilla but crashes IE. That is why we have chosen to fixed
     * this in Java by nulling out our reference to the XmlHttpRequest object.
     */
    final XMLHttpRequest xhr = xmlHttpRequest;
    xmlHttpRequest = null;

    xhr.clearOnReadyStateChange();
    xhr.abort();
  }
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

    /*
     * We cannot use cancel here because it would clear the contents of the
     * JavaScript XmlHttpRequest object so we manually null out our reference to
     * the JavaScriptObject
     */
    final XMLHttpRequest xhr = xmlHttpRequest;
    xmlHttpRequest = null;

    Response response = createResponse(xhr);
    callback.onResponseReceived(this, response);
  }
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

    }

    sb.append("]}");
    String jsonData = sb.toString();

    XMLHttpRequest xhr = XMLHttpRequest.create();
    xhr.open("POST", errorReportUrl + "?firstReport=" + firstReport);
    firstReport = false;
    xhr.send(jsonData);
  }
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

    String url = settings.getUrl();
    IsProperties data = settings.getData();
    String ctype = settings.getContentType();
    Boolean isFormData = data != null && data.getDataImpl() instanceof JavaScriptObject && JsUtils.isFormData(data.<JavaScriptObject>getDataImpl());

    XMLHttpRequest xmlHttpRequest = XMLHttpRequest.create();
    try {
      if (settings.getUsername() != null && settings.getPassword() != null) {
        xmlHttpRequest.open(httpMethod, url, settings.getUsername(), settings.getPassword());
      } else if (settings.getUsername() != null) {
        xmlHttpRequest.open(httpMethod, url, settings.getUsername());
      } else {
        xmlHttpRequest.open(httpMethod, url);
      }
    } catch (JavaScriptException e) {
      RequestPermissionException requestPermissionException = new RequestPermissionException(url);
      requestPermissionException.initCause(new RequestException(e.getMessage()));
      onError(null, e);
      return;
    }

    JsUtils.prop(xmlHttpRequest, "onprogress", JsUtils.wrapFunction(new Function() {
      public void f() {
        JsCache p = arguments(0);
        double total = p.getDouble("total");
        double loaded = p.getDouble("loaded");
        double percent = loaded == 0 ? 0 : total == 0 ? 100 : (100 * loaded / total);
        dfd.notify(total, loaded, percent, "download");
      }
    }));

    JavaScriptObject upload = JsUtils.prop(xmlHttpRequest, "upload");
    JsUtils.prop(upload, "onprogress", JsUtils.wrapFunction(new Function() {
      public void f() {
        JsCache p = arguments(0);
        double total = p.getDouble("total");
        double loaded = p.getDouble("loaded");
        double percent = 100 * loaded / total;
        dfd.notify(total, loaded, percent, "upload");
      }
    }));

    IsProperties headers = settings.getHeaders();
    if (headers != null) {
      for (String headerKey : headers.getFieldNames()) {
        xmlHttpRequest.setRequestHeader(headerKey, String.valueOf(headers.get(headerKey)));
      }
    }

    if (data != null && !isFormData && !"GET".equalsIgnoreCase(httpMethod)) {
      xmlHttpRequest.setRequestHeader("Content-Type", ctype);
    }

    // Using gQuery to set credentials since this method was added in 2.5.1
    // xmlHttpRequest.setWithCredentials(true);
    JsUtils.prop(xmlHttpRequest, "withCredentials", settings.getWithCredentials());

    final Request request = createRequestVltr(xmlHttpRequest, settings.getTimeout(), this);

    xmlHttpRequest.setOnReadyStateChange(new ReadyStateChangeHandler() {
      public void onReadyStateChange(XMLHttpRequest xhr) {
        if (xhr.getReadyState() == XMLHttpRequest.DONE) {
          xhr.clearOnReadyStateChange();
          fireOnResponseReceivedVltr(request, PromiseReqBuilder.this);
        }
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

     * Setting the onreadystatechange handler to null gives us the correct
     * behavior in Mozilla but crashes IE. That is why we have chosen to fixed
     * this in Java by nulling out our reference to the XmlHttpRequest object.
     */
    if (xmlHttpRequest != null) {
      XMLHttpRequest xmlHttp = xmlHttpRequest;
      xmlHttpRequest = null;

      xmlHttp.clearOnReadyStateChange();
      xmlHttp.abort();

      cancelTimer();
    }
  }
View Full Code Here

Examples of com.google.gwt.xhr.client.XMLHttpRequest

    /*
     * We cannot use cancel here because it would clear the contents of the
     * JavaScript XmlHttpRequest object so we manually null out our reference to
     * the JavaScriptObject
     */
    final XMLHttpRequest xhr = xmlHttpRequest;
    xmlHttpRequest = null;

    String errorMsg = getBrowserSpecificFailure(xhr);
    if (errorMsg != null) {
      Throwable exception = new RuntimeException(errorMsg);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.