【发布时间】:2011-05-19 13:42:22
【问题描述】:
我有一个基于 JSF2 和 RichFaces 的应用程序;我开发了一个使用 POI 以 PDF 格式导出一些数据的流程。
在我的 XHTML 中,我调用了一个方法:
<rich:modalPanel>
...
<p:commandButton image="/images/excel.png" action="#{managedBean.doXLS}" ajaxSingle="true" rendered="true" value="Exportar a XLS">
<f:setPropertyActionListener target="#{statisticsBean.optionToExport}" value="1"/>
</p:commandButton>
...
</rich:modalPanel>
我是这样通过 Java 调用的:
... // create XLS
response.setHeader( "Content-Disposition", "attachment; filename=\"" + nombreFichero + ".xls\"" );
response.setContentType("application/vnd.ms-excel");
OutputStream o = response.getOutputStream();
if ( workbook!=null && o!=null)
workbook.write(o);
o.flush();
o.close();
if (!FacesContext.getCurrentInstance().getResponseComplete())
FacesContext.getCurrentInstance().responseComplete();
没有抛出异常,但我的屏幕上什么也没有发生。有什么问题?
已解决:
好的,在与@BalusC(谢谢)交谈后,我无法响应“rich:modalPanel”中的文件,因为该文件是由 ajax 创建的。 NO MATHERS IF IS ajaxsingle 与否。
【问题讨论】:
标签: java jsf-2 richfaces download