1 2 3 4 Previous Next 56 Replies Latest reply on Sep 19, 2013 9:57 AM by haseeb Go to original post
      • 45. Re: workaround for multipleUpload capability in <rich:fileUpload>
        simone.83

        Okay! I'm looking for eventually bugs inside the fileupload.js...So what do you think about maxFileUpload="0"? The actual implementation will evaluate that as an unlimited upload.

        What do we do now in case of maxFileUpload="0" ??

        • 46. Re: workaround for multipleUpload capability in <rich:fileUpload>
          simone.83

          Ok, now I need just to change __addItem method inside fileupload.js (in attachments), fixing some bugs related to length var, that requires adding a new variable

          var itemsCount = this.__getTotalItemCount(),  then breaking the for loop and hiding the addButton when (this.maxFilesQuantity && (itemsCount >= this.maxFilesQuantity)),

          incrementing itemsCount only when inside the code for adding the item on list.

           

          For apply these changes do I wait your reply? I've seen that you have been updated the branch, and now I can't edit the fileupload.js file. Do I need to do a "fork"?

          (I'm a newbie in gists, sorry )

          • 47. Re: workaround for multipleUpload capability in <rich:fileUpload>
            lfryc

            The best option is actually using GitHub pull requests.

             

            If you fork the repository, then you can check it out locally, made changes, commit them by Git and send to your repository.

            Then, you just need to open Pull Request against the branch RF-12224-.. in GitHub interface. Once Pull Request will be opened, we can discuss changes there.

            • 48. Re: workaround for multipleUpload capability in <rich:fileUpload>
              simone.83

              I can't open the pull request ...I don't know why. I proceed with a fork ?

              • 49. Re: workaround for multipleUpload capability in <rich:fileUpload>
                lfryc

                Hey Simone, could you eventually join #richfaces channel at irc.freenode.net?

                It's little bit cumbersome to proceed here.

                 

                You can use web-client: http://webchat.freenode.net/

                 

                Thanks,

                 

                ~ Lukas

                • 50. Re: workaround for multipleUpload capability in <rich:fileUpload>
                  lfryc

                  Btw I have moved this discussion to RichFaces Development space.

                  • 51. Re: workaround for multipleUpload capability in <rich:fileUpload>
                    simone.83

                    I'll put here the diffs

                    • 52. Re: workaround for multipleUpload capability in <rich:fileUpload>
                      simone.83

                      Lukas, yesterday I made some changes and sent a pull request #79 but I was confused about ... and so today I've removed the pull request #79.

                       

                      Then I've been cleaned the implementation of the uploadable file check inside the method isUploadable.

                      NOTICE that we need also to put UIFileUpload.java inside the new 4.3.3 branch.

                       

                      I have no idea if its better to include that method inside the AbstractFileUpload.java (as you suggests in pull request #78 that I can't view anymore...probably because I've just removed my last pull request #79 or what?).

                      I think the isUploadable() method is not a property of the AbstractFileUpload object, but of the Entity who performs this check so the FileUploadRendererBase.

                      WDYT to include this method as a private method inside FileUploadRendererBase without change/add the getters inside the UIFileUpload / AbstractFileUpload ? .

                       

                      If you read my comments on pull #78, we need

                      - an hack inside fileupload.js inserting an hidden field with the this.__getTotalItemCount() value.

                      With that, we can have at server-side the updated value of all the files uploaded by the user (now we have only a per-request scope of uploaded files, not a global scope for the whole block),

                      and then we can add this check inside the boolean method, and check if T = this.__getTotalItemCount() is greater or equal than maxFilesUploaded we just return false in isUploadable,

                      so the UploadedFile will be rejected at server-side.

                       

                      - a - I don't know how - logic for discarding at server-side the duplicates. This is much more complicated because we don't have the full list at server side.

                            But this is not a great bug, the user can do that inside the listener for now. WDYT?

                       

                          public boolean isUploadable(UploadedFile uploadedFile) {

                              if (uploadedFile == null) return false;

                              String fileName = uploadedFile.getName();

                              List<String> acceptedTypesList = (List<String>) (Arrays.asList(getAcceptedTypes().replaceAll("\\s+", "").toLowerCase().split(",")));

                              if (acceptedTypesList.isEmpty())

                                  return true;

                              else if (acceptedTypesList.contains("") && acceptedTypesList.size() <= 1)

                                  return true; //fix the bug if no file suffix has specified but there are commas so empty string elements are in list!

                              int lastIndexOfDot = fileName.lastIndexOf('.');

                              if (lastIndexOfDot > -1) {

                                  String suffix = fileName.substring(lastIndexOfDot + 1).toLowerCase();

                                  return (acceptedTypesList).contains(suffix);

                              }

                              return false; 

                          }

                       

                      My boss is boring me because I've dedicated too much time in latest six days this RichFaces fix, and I need your help now, only for applying these changes into sources, can you?

                      If not, I need to do that only at home in the few hours of free time...

                       

                      thank you.

                      Simone

                      • 53. Re: workaround for multipleUpload capability in <rich:fileUpload>
                        simone.83

                        Hello Luk, this is the our last conversation in webirc chat.

                        • 54. Re: workaround for multipleUpload capability in <rich:fileUpload>
                          simone.83

                          ,,,and at this link you can download the .war with a demo of the our implementation of multiple file upload:

                           

                          http://www.megafileupload.com/en/file/431598/RF4MultipleUploadWEB-war.html

                           

                          (call it with this url: localhost:8080/RF4MultipleUploadWeb/faces/fileupload.xhtml)

                           

                          • 55. Re: workaround for multipleUpload capability in <rich:fileUpload>
                            haseeb

                            Hello All,

                            Simone you did really good job. Your solution works. It uploads multiple files but i have a problem it doesn't show list of files to be uploaded. I followed your instructions but this not working for me. Could you please guide me which particular code i should recheck for showing list?

                             

                            Another question is to Richfaces team that in which version/release they will merge these changes(multiple file upload) ?

                            Early response will be highly appreciated.

                            • 56. Re: workaround for multipleUpload capability in <rich:fileUpload>
                              haseeb

                              Hello,

                              I further investigated, after slight change in code, i can see list of files to be uploaded now. But now its another problem, it shows the progress of only one file(first) not for every files(one by one) but it uploads all files. How can i fix this issue??

                               

                              Anyone could help me in this regard??

                              1 2 3 4 Previous Next