Hello there:
I am trying to download a dynamically generated file.
It is not a real file I have in the server, but an "
Apache POI HSSFWorkbook", which can be
downloading by the client as an excel sheet (
HorribleSpreadSheetFormat :).
The download method is in a action-methode which I call from one page. I have to present the "download-Mask" and (after the download or the cancel) return to the same page.
So far so good and working well. I can open the downloaded file and it is all ok.
BUT
My problem is when I try to use another "action method" in that page (after the download)
it comes again the "download-Mask" !!
even if that has nothing to do with this other "action method".
So: something not closed? I try many other ways with no result...
CODE:
faces-config:
...
<managed-bean>
<managed-bean-name>downloadActions</managed-bean-name>
<managed-bean-class>jsfApp.logic.DownloadActions</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope></managed-bean>
...
<navigation-rule>
<from-view-id>/asls.jsp</from-view-id>
<navigation-case>
<from-outcome>process</from-outcome> <!-- the other feature on that page-->
<to-view-id>/asls.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>download</from-outcome> <!-- the d/l feature-->
<to-view-id>/asls.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>err</from-outcome>
<to-view-id>/errs.jsp</to-view-id>
</navigation-case>
</navigation-rule>
...
downloadMethod:
(as written above I already used other ways like: the write method from HSSFWorkbook, or other dispositions, etc.)
...
HttpServletResponse response = (HttpServletResponse)faces.getExternalContext().getResponse();
// text/plain vnd.ms-excel application/x-download
response.setContentType("vnd.ms-excel");
response.setHeader("Content-disposition","attachment; filename=\"myHSSF.xls\"");
ServletOutputStream out;
try {
out = response.getOutputStream();
out.write(theBytes);
out.flush();
}
...
faces.responseComplete();
...
page:
<h:commandLink id="expexcel" action="#{downloadActions.downloadMethod}" value="download"/>
Any ideas?
Thanks!
javo