DragAndDrop with <:pFileUpload component is not working on I

UI Components for JSF
Post Reply
nico5494
Posts: 2
Joined: 24 Oct 2016, 14:57

24 Oct 2016, 15:06

I don't succes to do a drag and drop because it's opening a new tab instead of drag and drop inside my component <:pFileUpload>

Code: Select all

  <p:fileUpload id="fileuploader"
                                  fileUploadListener="#..."
                                  cancelLabel="#{}"...
                                  uploadLabel="#...}"
                                  label="#...."
                                  mode="advanced"
                                  dragDropSupport="true"
                                  styleClass="fileupload-button"
                                  update="filesUploadList invUser"
                                  multiple="true"
                                  sizeLimit="10000000"
                                  invalidSizeMessage="#...." />


Moreover I used this bit of code to handle the problem with the drag and drop to handle one part of the problem

Code: Select all

 var $dropArea = $("#indexform\\:investigationData\\:fileuploader");
            $dropArea.on({
                "drop": makeDrop,
                "dragenter": ignoreDrag,
                "dragover": ignoreDrag
            });
            function ignoreDrag(e) {

                e.preventDefault();
            }

            function makeDrop(e) {

                var fileList = e.originalEvent.dataTransfer.files,
                        fileReader;
                e.preventDefault();
                e.
                if (fileList.length > 0) {
                    fileReader = new FileReader();
                    fileReader.readAsDataURL(fileList[ 0 ]);
                    $(".fileupload-content").trigger('drop', e); // Primefaces dropzone cssclass
                    var container = document.getElementById("indexform:investigationData:fileuploader");
                    var content = container.innerHTML;
                    container.innerHTML = content;
                }
            }
but I don't know how to manage my file after the drop to be prepare for the upload

If someone could help me, it will be wonderful.

Thanks ;)

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 26 guests