I have a Datatable in Primefaces with a celleditor to upload and download files. The file upload is working. The file download doesn't work, it only reloads the page. When I put the download Button direct under the p:column, the download is working. (So the download button is visible in edit mode)
What is wrong, any ideas?
Here is my code (simplified):
<p:column headerText="Header">
<!-- Download Button at this position works -->
<p:cellEditor>
<f:facet name="output">
<p:commandButton id="download" value="Download" ajax="false">
<p:fileDownload value="#{bean.downloadFile}" />
</p:commandButton>
</f:facet>
<f:facet name="input">
<p:fileUpload fileUploadListener="#{bean.uploadFile}" label="upload" mode="advanced" auto="true" process="@this" />
</f:facet>
</p:cellEditor>
</p:column>
And the managed bean:
import java.io.InputStream;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
public StreamedContent getDownloadFile() {
final InputStream stream = FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream("/images/test.png");
return new DefaultStreamedContent(stream, "image/png", "test.png");
}