示例#1
0
  public void getMessages() {

    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(URLGET));

    try {
      Request request =
          builder.sendRequest(
              null,
              new RequestCallback() {
                public void onError(Request request, Throwable exception) {}

                public void onResponseReceived(Request request, Response response) {
                  if (200 == response.getStatusCode()) {
                    IResponse serverResponse = decodeJSON(response.getText());
                    processResponse(serverResponse);

                  } else {

                    Window.alert("Messages couldn't  been recieved");
                  }
                }
              });
    } catch (RequestException e) {
      // Couldn't connect to server
    }
  }
示例#2
0
  public static void fbLogin(String profileId) throws RequestException {
    RequestBuilder builder =
        new RequestBuilder(
            RequestBuilder.POST, "http://localhost:8080/j_spring_service_security_check");
    builder.setHeader("Content-type", "application/x-www-form-urlencoded");
    builder.sendRequest(
        "profile_id=" + profileId + "&service_name=facebook",
        new RequestCallback() {
          @Override
          public void onResponseReceived(Request request, Response response) {
            if (response.getStatusCode() < 400) {
              History.newItem("photo");
            }
          }

          @Override
          public void onError(Request request, Throwable exception) {
            return;
          }
        });
  }
示例#3
0
  private void getAllTreeLessons() {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URLConstants.JSON_LESSONS);
    try {
      builder.sendRequest(
          null,
          new RequestCallback() {
            public void onError(Request request, Throwable exception) {
              displayError("Couldn't retrieve JSON : " + exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
              if (Response.SC_OK == response.getStatusCode()) {
                buildLessonTree(response);
              } else {
                displayError("Couldn't retrieve JSON (" + response.getStatusText() + ")");
              }
            }
          });
    } catch (RequestException e) {
      displayError("Couldn't retrieve JSON : " + e.getMessage());
    }
  }