<div dir="ltr">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.<div><br></div><div>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&#39;t really get inspired elsewhere.</div>

<div><br></div><div>Note: the only such implementation is PrimeFaces but they don&#39;t use standard JSF AJAX (jsf.ajax.request function), they use jQuery.ajax<br></div><div><br></div><div><br></div><div><br></div><div>If we look into implementation of jsf.js, XMLHttpRequest (XHR) is not really exposed anywhere, not even on onevent(&#39;begin&#39;) [1].</div>

<div><br></div><div>I believe it would be significant improvement to expose XHR instance used to drive given JSF AJAX request here, that&#39;s why I will fill JAVASERVERFACES (and MyFaces) issue</div><div><br></div><div>
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&#39;s also the approach that we use in Graphene [3] (the impl there is actually more powerful than we need here).</div>

<div><br></div><div>Even though, Graphene implementation is proven to work cross-browser:</div><div>* IE8+ (IE7 and less is not worth the trouble)</div><div>* Firefox, Chrome, Safari</div><div>* Opera support unknown</div>

<div><br></div><div><br></div><div><br></div><div><br></div><div>The idea is that we can:</div><div><br></div><div>1. override a XHR.open method just before jsf.ajax.request</div><div>2. wait for call to XHR.open and store reference to the invoked XHR instance</div>

<div>3. override a XHR.open method back just after jsf.ajax.request method</div><div><br></div><div>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 &quot;uploading&quot; and &quot;upload completed&quot; states.</div>

<div><br></div><div>There are two possible places for overriding:</div><div>1. richfaces.js intercepts calls to jsf.ajax.request already [5]</div><div>2. in fileupload.js [6] - note: I&#39;m not sure whether we should do submitForm here, we may use RichFaces.ajax / jsf.ajax.request</div>

<div><br></div><div><br></div><div>~ Lukas</div><div><br></div><div><br></div><div>[1] <a href="https://github.com/jboss/mohttp://stackoverflow.com/questions/629671/how-can-i-intercept-xmlhttprequests-from-a-greasemonkey-scriptjarra/blob/2.2.5-jbossorg-3/jsf-api/src/main/resources/jsf.js#L1958">https://github.com/jboss/mohttp://stackoverflow.com/questions/629671/how-can-i-intercept-xmlhttprequests-from-a-greasemonkey-scriptjarra/blob/2.2.5-jbossorg-3/jsf-api/src/main/resources/jsf.js#L1958</a></div>

<div>[2] <a href="http://stackoverflow.com/questions/629671/how-can-i-intercept-xmlhttprequests-from-a-greasemonkey-script">http://stackoverflow.com/questions/629671/how-can-i-intercept-xmlhttprequests-from-a-greasemonkey-script</a></div>

<div>[3] <a href="https://github.com/arquillian/arquillian-graphene/blob/master/impl/src/main/javascript/Graphene.xhrInterception.js">https://github.com/arquillian/arquillian-graphene/blob/master/impl/src/main/javascript/Graphene.xhrInterception.js</a></div>

<div>[4] <a href="http://www.w3schools.com/browsers/browsers_explorer.asp">http://www.w3schools.com/browsers/browsers_explorer.asp</a></div><div>[5] <a href="https://github.com/richfaces/richfaces/blob/master/framework/src/main/resources/META-INF/resources/org.richfaces/richfaces.js#L583">https://github.com/richfaces/richfaces/blob/master/framework/src/main/resources/META-INF/resources/org.richfaces/richfaces.js#L583</a></div>

<div>[6] <a href="https://github.com/richfaces/richfaces/blob/master/framework/src/main/resources/META-INF/resources/org.richfaces/input/fileUpload/fileupload.js#L252">https://github.com/richfaces/richfaces/blob/master/framework/src/main/resources/META-INF/resources/org.richfaces/input/fileUpload/fileupload.js#L252</a></div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 13, 2014 at 3:55 PM, Lukáš Fryč <span dir="ltr">&lt;<a href="mailto:lukas.fryc@gmail.com" target="_blank">lukas.fryc@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">We need to check all the criteria that file upload defines on both, server-side and client-side.<div>Otherwise an &quot;attacker&quot; could bypass the criteria by modifying client-side code.</div>

</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Feb 13, 2014 at 3:14 PM, Michal Petrov <span dir="ltr">&lt;<a href="mailto:richfaces-dev@lists.jboss.org" target="_blank">richfaces-dev@lists.jboss.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


{quote:modifiedtitle=true|class=jive_text_macro jive_macro_quote}<br>
<div>ad) new widget<br>
<br>
<br>
<br>
we might want to do more rigorous search for alternative widgets.<br>
<br>
<br>
<br>
Let&#39;s collect requirements here:<br>
<br>
<br>
<br>
<br>
*<br>
drag-drop<br>
<br>
<br>
*<br>
progress indication<br>
<br>
<br>
*<br>
file size limits<br>
<br>
<br>
*<br>
rejection per file / mime-type<br>
<br>
<br>
<br>
<br>
<br>
(practically all things original widget had, just client-side)<br>
</div>{quote}<br>
I will take a look but those requirements do not seem hard to implement if we needed to. Drop support in particular is just a listener for drop event and can be easily added to the current fileUpload.<br>
<br>
Concerning the server side what are the requirements past sending the files to a servlet, are we letting the user handle it?<br>
<br>
Posted by forums<br>
Original post: <a href="https://community.jboss.org/message/857511#857511" target="_blank">https://community.jboss.org/message/857511#857511</a><br>
<div><div>_______________________________________________<br>
richfaces-dev mailing list<br>
<a href="mailto:richfaces-dev@lists.jboss.org" target="_blank">richfaces-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/richfaces-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/richfaces-dev</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>