【发布时间】:2016-10-03 13:05:37
【问题描述】:
我正在使用 Primefaces monitorDownload (PF 3.4.2)。
我想创建一个文件并使用命令按钮下载它。单击按钮,停止功能在启动功能之后立即触发。然后生成+下载请求正确完成。所以 end 函数不会在下载结束时触发,而是在开始时触发,与 start 函数相同。
不是我想要的。我想要这个场景:
- 点击按钮
- 出现正在加载的纺车(显示正在生成)
- 文件的生成
- 加载旋转消失
- 浏览器的文件下载请求
那里有我的代码:
<h:form>
<pf:panel>
<pf:commandButton value="Export database" id="exportDatabase" ajax="false" onclick="PrimeFaces.monitorDownload(window.alert('start'), window.alert('stop'));">
<pf:fileDownload value="#{bean.exportDatabase()}" />
</pf:commandButton>
</pf:panel>
</h:form>
豆面:
private StreamedContent exportDatabaseFile;
public StreamedContent exportDatabase() {
String exportDatabaseFilename = "nameOfTheFile.xlsx";
Path nameExportDatabasePath = "C:\nameOfTheFile.xlsx";
// Populate exportDatabaseFile
exportDatabaseFile = new DefaultStreamedContent(new FileInputStream(nameExportDatabasePath.toFile()), FacesContext.getCurrentInstance().getExternalContext().getMimeType(exportDatabaseFilename), exportDatabaseFilename);
return exportDatabaseFile;
}
知道如何解决这个问题吗?
【问题讨论】:
-
这个问题你解决了吗?
标签: jsf primefaces