As Michal mentioned on the team meeting, we are not able to hook into XMLHttpRequest object that we need to make client-side progress tracking work.
We did a bit of research with Brian yesteday and found out that there is no other library that would do what we want to achieve, so we can't really get inspired elsewhere.
Note: the only such implementation is PrimeFaces but they don't use standard JSF AJAX (jsf.ajax.request function), they use jQuery.ajax
If we look into implementation of jsf.js, XMLHttpRequest (XHR) is not really exposed anywhere, not even on onevent('begin') [1].
I believe it would be significant improvement to expose XHR instance used to drive given JSF AJAX request here, that's why I will fill JAVASERVERFACES (and MyFaces) issue
Fortunately, there is a way how to hook into XHR instance itself - it is possible to intercept XHR.open method [2] by overriding its declaration. That's also the approach that we use in Graphene [3] (the impl there is actually more powerful than we need here).
Even though, Graphene implementation is proven to work cross-browser:
* IE8+ (IE7 and less is not worth the trouble)
* Firefox, Chrome, Safari
* Opera support unknown
The idea is that we can:
1. override a XHR.open method just before jsf.ajax.request
2. wait for call to XHR.open and store reference to the invoked XHR instance
3. override a XHR.open method back just after jsf.ajax.request method
These steps should be performed in a try {} catch {} block and if we do not succeed to obtain XHR instance this way, we should perform fallback to show progress bar that reflects "uploading" and "upload completed" states.
There are two possible places for overriding:
1. richfaces.js intercepts calls to jsf.ajax.request already [5]
2. in fileupload.js [6] - note: I'm not sure whether we should do submitForm here, we may use RichFaces.ajax / jsf.ajax.request
~ Lukas