Dynamic amount of fileuploadsfileuploads: file not uploading
I'd like to give the user the ability to choose the amount of attachments he'd like to provide. To do this I created a datatable with buttons to add and remove attachment-lines:
<p:dataTable id="attachments" var="attachment" value="#{data.attachments}">
<p:column headerText="#{ivy.cms.co('/labels/vendor')}"><p:inputText value="#{attachment.vendor}" /></p:column>
<p:column headerText="#{ivy.cms.co('/labels/description')}"><p:inputText value="#{attachment.description}" /></p:column>
<p:column headerText="#{ivy.cms.co('/labels/amount')}"><p:inputText value="#{attachment.amount}" /></p:column>
<p:column headerText="#{ivy.cms.co('/labels/attachment')}"><p:fileUpload value="#{attachment.file}" mode="simple" /></p:column>
<p:column headerText=""><p:commandButton value="delete-row" update="attachments" action="#{logic.deleteAttachment(attachment)}" /><p:commandButton value="add-row" update="attachments" action="#{logic.addAttachment()}" /> </p:column>
</p:dataTable>
The only problem is, that it seems to not upload the specified file. The submitted form is beeing processed by this script, the output of **in.test** beeing **false**:
for(Integer i = 0; i < in.attachments.size(); i++) {
in.test = in.attachments.get(i).file.exists().toString();
}
The Simple-Fileupload-Demo works, so I guess it can't be a problem with my installation / computer. I just cleared all of the attachments and uploaded only one. So while this is a foor loop, it just iterates through 1 time. Data is stored in my own Data Class **Attachment**, containing 4 attributes (Vendor, Description, Amount and File).