I have a simple upload listener inside a view scoped bean that, for each file uploaded, adds it to a list and than displays the list.
The problem is that, when I press the upload button to upload more than one file at once, only one of the files is added to the list and no exception is shown. On the other hand, if I do the upload of a single file, waiting the previous to complete, the behavior is normal.
I thought of some concurrency problem but then, when I tried to put the bean in session scope, it worked correctly. Is it possible that a concurrency problem invalidates the view?
Any other suggestion? Thanks a lot
<h:form id="form" enctype="multipart/form-data">
<p:wizard widgetVar="wiz" render="true" id="wizard">
<p:tab id="p0" title="file upload" step="0">
<p:panel>
<p:fileUpload
fileUploadListener="#{myBean.uploadedFile}"
mode="advanced" multiple="true" sizeLimit="100000"
update="fileList"/>
<p:dataList id="fileList" value="#{myBean.filesName}" var="file">#{file}</p:dataList>
The bean:
public void uploadedFile(FileUploadEvent event) {
try {
files.add(event.getFile());
filesName.add(event.getFile().getFileName());
} catch (Exception e) {
e.printStackTrace();
}
}