Wednesday, November 27, 2013

GWT FileUpload with Progress Listener

 want to observe the upload percentage of a file upload from GWT.

In JavaScript you can use a XMLHttpRequest and add an event listener like this:

var oReq = new XMLHttpRequest();    oReq.upload.addEventListener("progress", updateProgress, false);    // progress on transfers from the server to the client (downloads)  function updateProgress (oEvent) {    if (oEvent.lengthComputable) {      var percentComplete = oEvent.loaded /;      // ...    } else {      // Unable to compute progress information since the total size is unknown    }  }

(The above code is from here.)

This is also done very easily in jQuery as:

 var $request = $.ajax({        xhr: function() {          xhrNativeObject = new window.XMLHttpRequest();          //Upload progress          xhrNativeObject.upload.addEventListener("progress", function(event) { ... }        }   });

I want to do the same with GWT. I could use a RequestBuilder to send a request, but this is only a high level wrapper around the XMLHttpRequest JavaScriot object. Another possibility would be to use the GWT XMLHttpRequest class which is a JSNI wrapper of the JavaScript XMLHttpRequest.

My problem:

How can I add a progress listener to the XMLHttpRequest or the RequestBuilder?

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment