Package com.google.gwt.http.client

Examples of com.google.gwt.http.client.RequestCallback


        @Override
        void send(String message, final AsyncCallback<Void> callback) {
            RequestBuilder request = new RequestBuilder(RequestBuilder.POST, serviceUrl());
            try {
                request.sendRequest(message, new RequestCallback() {
                    @Override
                    public void onResponseReceived(Request request, Response response) {
                        // when a connection is abruptly closed (for instance when a user presses F5
                        // the statuscode seems to be 0, the call could have arrived at the server though
                        if (response.getStatusCode() != Response.SC_OK
View Full Code Here




  @Override
  protected RequestCallback createRequestCallback(final TransportReceiver receiver) {
    return new RequestCallback() {

      public void onError(Request request, Throwable exception) {
        wireLogger.log(Level.SEVERE, SERVER_ERROR, exception);
        receiver.onTransportFailure(new ServerFailure(exception.getMessage(), getExceptionName(exception), null, true));
      }
View Full Code Here

        final RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST, "j_security_check");
        requestBuilder.setHeader("Content-Type","application/x-www-form-urlencoded");
        requestBuilder.setHeader("X-Requested-With","XMLHttpRequest");
        try {
            view.setWaiting(true);
            requestBuilder.sendRequest(createLoginPostData(login), new RequestCallback() {

                @Override
                public void onResponseReceived(final Request request, final Response response) {
                    final int statusCode = response.getStatusCode();
                    if(statusCode == Response.SC_OK) {
View Full Code Here

              final Node transformTarget = target;

              logger.log(Level.FINE, "Aynchronous GET for: " + asyncSourceURI);
              final HTTPHandler hr = new HTTPHandler();

             hr.doGet(asyncSourceURI, new RequestCallback() {
              
               public void onError(Request request, Throwable exception) {
                 //hr.setErrorMessage(exception.getMessage());
                 String msg = "HTTP Error " + exception.getMessage() + " for URI " + URI;
                 handleException (new RuntimeException(msg), "onError");
View Full Code Here

    public void send() {
        timer.cancel();

        final RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, uri);

        final RequestCallback callback = new RequestCallback() {

            @Override
            public void onResponseReceived(Request request, Response response) {
                int status = response.getStatusCode();

                // Notify network observers about response status
                connection.fireEvent(new ConnectionStatusEvent(status));

                if (status == Response.SC_OK) {
                    getLogger().fine("Heartbeat response OK");
                } else if (status == 0) {
                    getLogger().warning(
                            "Failed sending heartbeat, server is unreachable, retrying in "
                                    + interval + "secs.");
                } else if (status >= 500) {
                    getLogger().warning(
                            "Failed sending heartbeat, see server logs, retrying in "
                                    + interval + "secs.");
                } else if (status == Response.SC_GONE) {
                    connection.showSessionExpiredError(null);
                    // If session is expired break the loop
                    return;
                } else {
                    getLogger().warning(
                            "Failed sending heartbeat to server. Error code: "
                                    + status);
                }

                // Don't break the loop
                schedule();
            }

            @Override
            public void onError(Request request, Throwable exception) {
                getLogger().severe(
                        "Exception sending heartbeat: "
                                + exception.getMessage());
                // Notify network observers about response status
                connection.fireEvent(new ConnectionStatusEvent(0));
                // Don't break the loop
                schedule();
            }
        };

        rb.setCallback(callback);

        try {
            getLogger().fine("Sending heartbeat request...");
            rb.send();
        } catch (RequestException re) {
            callback.onError(null, re);
        }

    }
View Full Code Here

     *            The URI to use for the request. May includes GET parameters
     * @param payload
     *            The contents of the request to send
     */
    protected void doUidlRequest(final String uri, final JSONObject payload) {
        RequestCallback requestCallback = new RequestCallback() {
            @Override
            public void onError(Request request, Throwable exception) {
                handleCommunicationError(exception.getMessage(), -1);
            }

View Full Code Here

  /** This class is a Timer that sends a keepalive message periodically */
  private class KeepaliveTimer extends Timer {
    @Override
    public void run() {
      FreenetRequest.sendRequest(UpdaterConstants.keepalivePath, new QueryParameter("requestId", FreenetJs.requestId), new RequestCallback() {
        @Override
        public void onResponseReceived(Request request, Response response) {
          // If not success, then close the connection
          if (response.getText().compareTo(UpdaterConstants.SUCCESS) != 0) {
            if (firstSuccess == false) {
View Full Code Here

  /** Sends a request */
  private void sendRequest() {
    // Only send if running
    if (running == true) {
      sentRequest = FreenetRequest.sendRequest(UpdaterConstants.notificationPath, new QueryParameter("requestId", FreenetJs.requestId), new RequestCallback() {
        @Override
        public void onResponseReceived(Request request, Response response) {
          FreenetJs.log("AJAX response:success:" + (response.getText().startsWith(UpdaterConstants.SUCCESS) ? "true" : "false"));
          if (response.getText().startsWith(UpdaterConstants.SUCCESS)) {
            // If success, then notify the UpdateManager
View Full Code Here

        hideElement.addMouseDownHandler(new MouseDownHandler() {
          @Override
          public void onMouseDown(MouseDownEvent event) {
            // Only send a request if the message is originated from the server
            if (m.getAnchor() != null) {
              FreenetRequest.sendRequest(UpdaterConstants.dismissAlertPath, new QueryParameter("anchor", m.getAnchor()), new RequestCallback() {
                @Override
                public void onResponseReceived(Request request, Response response) {
                  // When a response is got, the server is already removed the message. We can remove it too safely
                  removeMessage(m);
                }
View Full Code Here

        queryString = queryString.concat("&");
      }
    }
    // If no callback was specified, then create an empty one
    if (callback == null) {
      callback = new RequestCallback() {

        @Override
        public void onResponseReceived(Request request, Response response) {
        }
View Full Code Here

TOP

Related Classes of com.google.gwt.http.client.RequestCallback

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.