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<https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest>
.)
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<http://www.gwtproject.org/javadoc/latest/com/google/gwt/http/client/RequestBuilder.html>
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<http://www.gwtproject.org/javadoc/latest/com/google/gwt/xhr/client/XMLHttpRequest.html>
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.