I'm having difficulty trying to get my program to use <p:fileDownload/>
my button press to trigger it.
<p:commandButton>
<p:fileDownload value="#{searchBean.currentSearch.file}"/>
</p:commandButton>
my code to download it
public StreamedContent getFile() throws FileNotFoundException
{
InputStream stream = new FileInputStream(new File(ppath + ".csv"));
StreamedContent temp = new DefaultStreamedContent(stream, "download/csv", ppath + ".csv");
return temp;
}
I have checked in debug mode stream is not null and the file does exist. I'm using hosting using glassfish 3.1. Any ideas where I am going wrong?
Try setting ajax to false.
<p:commandButton ajax="false">
<p:fileDownload value="#{searchBean.currentSearch.file}"/>
</p:commandButton>