I have a problem with the component p:fileDownload.
I have a dataTable wich presents documents that can be downloaded.
page.xhtml :
Code: Select all
<p:dialog header="..." widgetVar="popup">
<h:form id="dar_ac_popDocs_form" prependId="false" enctype="multipart/form-data">
... file upload to upload a new document ...
<p:dataTable id="dar_ac_popDocs_dataTable_docs" value="#{essaiManager.documents}" var="document" emptyMessage="#{resourceBundle['results.none']}">
<p:column id="nom">
<f:facet name="header"><h:outputText value="#{resourceBundle['document.nom']}" /></f:facet>
<h:outputText value="#{document.nom}" />
</p:column>
<p:column id="dwd">
<p:commandLink ajax="false" title="#{resourceBundle['file.dwd']}">
<h:graphicImage library="images" name="download.gif" alt="#{resourceBundle['file.dwd']}" />
<p:fileDownload value="#{fileDwdController.downloadDocument(document)}" />
</p:commandLink>
</p:column>
</p:dataTable>
...
</h:form>
</p:dialog>
Code: Select all
public class DocumentDownloadController
{
public StreamedContent downloadDocument(final Document doc)
{
InputStream stream = ... ;
String fileName = ... ;
String applicationType = ...;
return new DefaultStreamedContent(stream,
applicationType,
fileName);
}
}
In fact, it seems that the download-events are not purged when a download occur. Consequently, the next event will be added in the queue events and all of them will be processed. So, it is not the good files that are downloaded.
To illustrate my problem, I have put the fllowing breakpoints in the java code :
B1 : org.primefaces.component.filedownload.FileDownloadActionListener.processAction (l.45)
B2 : DocumentDownloadController.downloadDocument
Exemple that shows the problem :
I have two documents on my table :
doc 1 download 1
doc 2 download 2
STEP 1: click on download 1
1) An event is processed by the FileDownloadActionListener ok
2) My controller is called with doc1 ok
3) The user can download doc 1 ok
STEP 2: click on download 2
1) An event is processed by the FileDownloadActionListener ??
2) My controller is called with doc1 ??
3) An event is processed by the FileDownloadActionListener ok
4) My controller is called with doc2 ok
5) The user can download doc 2 ok
STEP 3 : click on download 1
1) An event is processed by the FileDownloadActionListener ok
2) My controller is called with doc1 ok
3) An event is processed by the FileDownloadActionListener ??
4) My controller is called with doc2 ??
5) The user can download doc 2 KO!
I really don't understand this problem of events processing. How can I solve my problem please?
Thanks.