単純なファイルのダウンロードを機能させようとしていますが、AJAX ステータス バーがハングしているだけです。バッキング Bean の出力は、準備とダウンロードで正しい名前をレンダリングします。
私はこれを間違っていますか?両方の出力が正しいようです。
JSF 2.0 プライムフェイス 3.4
<h:form>
<p:commandButton id="downloadLink" value="Download" actionListener="#{filemanagement.prepDownload}">
<p:fileDownload value="#{filemanagement.download}" />
</p:commandButton>
</h:form>
バッキング Bean:
private DefaultStreamedContent download;
public void setDownload(DefaultStreamedContent download) {
this.download = download;
}
public DefaultStreamedContent getDownload() throws Exception {
System.out.println("GET = " + download.getName());
return download;
}
public void prepDownload() throws Exception {
File file = new File("C:\\file.csv");
InputStream input = new FileInputStream(file);
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
setDownload(new DefaultStreamedContent(input, externalContext.getMimeType(file.getName()), file.getName()));
System.out.println("PREP = " + download.getName());
}