Thursday, November 28, 2013

Re: GWT FileUpload with Progress Listener

Yes, but I do not get how to use it. Can you help me with this please?

Am Donnerstag, 28. November 2013 12:20:21 UTC+1 schrieb Thomas Broyer:
Have you checked Elemental? AFAICT, everything's there already.
http://www.gwtproject.org/articles/elemental.html

On Wednesday, November 27, 2013 4:02:48 PM UTC+1, confile wrote:

 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 / oEvent.total;      // ...    } 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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment