Package com.google.gwt.query.client

Examples of com.google.gwt.query.client.IsProperties


    if (s.getTimeout() > 0) {
      c.setConnectTimeout(s.getTimeout());
      c.setReadTimeout(s.getTimeout());
    }
   
    IsProperties headers = s.getHeaders();
    if (headers != null) {
      for (String h : headers.getFieldNames()) {
        c.setRequestProperty(h, "" + headers.get(h));
      }
    }
   
    if (s.getType().matches("POST|PUT")) {
      c.setRequestProperty("Content-Type", s.getContentType());
View Full Code Here


    return (IsProperties)Proxy.newProxyInstance(IsProperties.class.getClassLoader(), new Class[] {IsProperties.class}, handler);
  }

  @Override
  public IsProperties create(String s) {
    IsProperties ret = createBinder();
    ret.parse(s);
    return ret;
  }
View Full Code Here

  public String getModuleName() {
    return null;
  }

  public void testPropertiesCreate() {
    IsProperties p1 = GQ.create();
    p1.set("a", "1");
    p1.set("b", 1);
    p1.set("c", "null");
    p1.set("d", null);

    assertEquals("1", p1.get("a"));
    assertEquals(Double.valueOf(1), p1.get("b"));
    assertEquals("null", p1.get("c"));
    assertNull(p1.get("d"));

    p1 = GQ.create(p1.toJson());

    assertEquals("1", p1.get("a"));
    assertEquals(Double.valueOf(1), p1.get("b"));
    assertEquals("null", p1.get("c"));
    assertNull(p1.get("d"));
  }
View Full Code Here

   * javascript data (like forms in modern html5 file api)
   */
  public PromiseReqBuilder(Settings settings) {
    String httpMethod = settings.getType();
    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);
View Full Code Here

 
  private Promise performAjaxJsonTest(Settings s) {
    delayTestFinish(5000);
    return Ajax.ajax(s)
      .done(new Function(){public void f() {
        IsProperties p = arguments(0);
        assertEquals("abc", p.get("a"));
        finishTest();
      }})
      .fail(failFunction);
  }
View Full Code Here

    delayTestFinish(5000);
    // Use a public json service supporting callback parameter
    Ajax.getJSONP("https://www.googleapis.com/blogger/v2/blogs/user_id/posts/post_id?callback=?&key=NO-KEY")
      .done(new Function(){
        public void f() {
          IsProperties p = arguments(0);
          // It should return error since we do not use a valid key
          // {"error":{"errors":[{"domain":"usageLimits","reason":"keyInvalid","message":"Bad Request"}],"code":400,"message":"Bad Request"}}
          assertEquals(400, p.<IsProperties>get("error").<Number>get("code").intValue());
          finishTest();
        }
      })
      .fail(failFunction);
  }
View Full Code Here

    if ("jsonp".equalsIgnoreCase(settings.getDataType())) {
      type = "GET";
    }
    settings.setType(type);

    IsProperties data = settings.getData();
    if (data != null) {
      String dataString = null, contentType = null;
      if (data.getDataImpl() instanceof JavaScriptObject && JsUtils.isFormData(data.<JavaScriptObject>getDataImpl())) {
        dataString = null;
        contentType = FormPanel.ENCODING_URLENCODED;
      } else if (settings.getType().matches("(POST|PUT)") && "json".equalsIgnoreCase(settings.getDataType())) {
        dataString = data.toJson();
        contentType = JSON_CONTENT_TYPE_UTF8;
      } else {
        dataString = data.toQueryString();
        contentType = FormPanel.ENCODING_URLENCODED;
      }
      settings.setDataString(dataString);
      settings.setContentType(contentType);
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.query.client.IsProperties

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.