'PrimeFaces uploadFile, trying to upload multiple files and stopping at one

So basically, I have a fileUploader that I want to do multiple files at a time. When I click upload with 2 or more files, it runs the event handler once, and then stops, not running it again for the rest of the files, even though it shows them in queue on the page.

        <h:panelGroup>                               
            <h:panelGrid columns="3" >
                <h:outputText value="Attach Files:"/>
                <p:fileUpload allowTypes="/(\.|\/)(doc|docx|xls|xlsx|pdf)$/" mode="advanced" multiple="true" sizeLimit="30000000" auto="true" fileUploadListener="#{requestPart.handleFileUpload}" update="messages"/>
                <p:messages id="mgs" showDetail="true"/> 
            </h:panelGrid>
        </h:panelGroup>

My event handler code is as follows

private List<UploadedFile> uploadedFileList = new ArrayList<UploadedFile>();

public void handleFileUpload(FileUploadEvent event) throws NotSupportedException, SystemException, SQLException
{

    System.out.println("Uploading Request Part files....");
    UploadedFile file = event.getFile();
    uploadedFileList.add(file);
    FacesMessage msg = new FacesMessage("File attached successfully.", file.getFileName() + " is uploaded.");  
    FacesContext.getCurrentInstance().addMessage(null, msg);  

}

Could anyone point me in the write direction? As far as I know, the event is just one file at a time and never a list?



Solution 1:[1]

Which version of PF? I had similar problem with PF 5.0. Try with this:

    public static synchronized void addToList{
    uploadedFileList.add(file);
    }

Solution 2:[2]

My solution is:

sequential="true" add in your fileUpload and your bean

 private List<UploadedFile> archImagen;

 public void handleFileUpload(FileUploadEvent event) {
        archImagen.add( event.getFile()); 
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cctt
Solution 2 MBT