-
Notifications
You must be signed in to change notification settings - Fork 42
RF-12224: FileUpload - initial support for multiple file selection #78
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we just change maxFilesQuantity
attribute to Integer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes of course we could, so I've changed related getter inside the AbstractFileUpload. See next comment.
:+1 . In this method we also need (but I'm sure that we cannot do that modifing only few sources :( ): <-- ahahah
OoooooooooooooookaY? ^ not intentionally, I've mirrored the worry face :( |I'm a mirror| ): !!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have to add
var itemsCount = this.__getTotalItemCount();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value should be cached in the component using the StateHelper, something like:
String acceptedTypes = (String) getStateHelper().eval("acceptedTypes");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the we delegate to abstract method, which is implemented by UIFileUpload
as:
public String getAcceptedTypes() {
String value = (String) getStateHelper().eval(Properties.acceptedTypes);
return value;
}
This looks really good, thanks for taking the time to create the patch @simone83! I made a couple comments inline. Regarding the need for a multiple=true/false attribute for backwards compatibility, it's hard to say. I'd like to see what the usage of the fileupload component looks like with this new feature in place. I'll build the component in this branch, and try it in the showcase to try it out. |
Ok, I tired it in the showcase - it works great. I can't think of a use case for requiring users to select only a single file at a time, particularly with the |
Possible bug: I tried uploading 2 files, the first one threw an exception that the filesize is too big, this blocked the upload of the 2nd file which was acceptable. Clicking the upload button a 2nd time allowed the upload time of the 2nd file to proceed. IMO, if a file is invalid to be uploaded, it should not block the remaining files waiting to be uploaded. |
Brian, thank you. I'm glad to join in richfaces community with great guys like you and lukas and give my contrib when i can. Concerning the getMaxFilesQuantity set to be 1 in case of single file at a time, note also we must mantain backward compatibility with some browsers like IE7 that does not recognize the multiple attribute in html component. In my first patch, and its subsequently changes it works in both versions of browsers. If u take a look inside fileupload.js in fact you can see the support for oldiest browsers: then the things should works on oldiest IE browsers and in newest Firefox too: the code in fileupload.js recognize if multiple upload is supported then will go in multiple mode, else it works in single upload mode (it does an if (this.input.prop("files")) so if it is true we are running on a browser that supports multiple upload, else nothing to do :( we have to go in single upload mode). |
Notice also we can do that (valid only on browsers that supports the multiple attribute):
so we can act inside fileupload.js for implement client-side verification of maximum-file size exceed treshold,
Notice also for mantaining the compatibility with single mode upload, where we can't rely on size attribute, we also need to delegate at user-implementation inside the bean listener to check the max treshold of a file size. |
Setting
But like I was saying, I don't think we need to provide an option to limit file selection to one at a time. If the browser supports it, let's run with it. As for the Exception thrown while uploading a group of files, we should either:
My preference is for 1) |
Ok,i agree...that behavior of maxfilesquantity was well knew by me but probably I misread your related post reading "can" instead of "can't" sorry:( |
Brian, I've done a new post (new re-edited for last time) concerning the "withoutextension." files,please read it because it is important...in it i describe a NEW FIX that resolves an issue in case of acceptedTypes=",EXT1,EXT2,...,EXTN" ...thank you! |
We don't have to go so far as to get the acceptedTypes attribute to work with empty extensions, but rather we should have the component fail when a file with an empty extension is uploaded (for example if I leave acceptedTypes unspecified). |
I'm going to work on merging this into RF 4.5.0 branch. |
Merged: 72417a9 |
Opening pull request for a review.