Wednesday, November 27, 2013

Re: GWT FileUpload with Progress Listener

Well if you already know the concept of JSNI then you can use it to add a listener to GWT's XMLHttpRequest as its an ordinary JavaScriptObject. You either extend it or create a utility method. Something along these lines (probably not fully correct):

public native void setProgressListener(MyProgressListener p) /*-{
  this.upload.addEventListener("progress", function(event) {
  }, false);

A utility method would have an additional XMLHttpRequest parameter and use request.upload instead of this.upload.

Don't forget to cleanup the event listener after you are done. Also note that XMLHttpRequest.create() can return an IE specific object which might not support the progress feature or which requires you do register the listener differently. So your implementation might be a bit more complicated depending on your browser support requirements.

-- J.

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