I,m Using JSF 2.0 and the PrimeFace lib to offer a file download. I don't know why the file download is working just one time. When trying again, then the whole page is offered as download with the same file name...
her is a code snippet:
Facelet:
Code: Select all
<h:commandLink value="Download">
<p:fileDownload value="#{mybean.downloadFile}"/>
</h:commandLink>
Code: Select all
private StreamedContent downloadFile;
public StreamedContent getDownloadFile() {
return downloadFile;
}
public void setDownloadFile(StreamedContent downloadFile) {
this.downloadFile = downloadFile;
}
....
InputStream stream = new FileInputStream(targzFile);
StreamedContent file = new DefaultStreamedContent(stream, "application/gzip",
targzFile.getName());
setDownloadFile(file);
greetings
maxpade