2016-12-30 54 views
-2

我需要從模態對話框中的數據表內使用PrimeFaces p:fileDownload,但由於使用了ajax =「false」(else文件下載將不會被觸發)內部的命令按鈕對話框消失。你有任何線索嗎?p:fileDownload不能在模態對話框中工作(由於ajax =「false」)

<p:commandLink value="#{row.name}" ajax="false" 
actionListener="#{documentsBean.fileDownloadController(row)}"> 
<p:fileDownload value="#{documentsBean.fileStream}" /> 
</p:commandLink> 

以上是命令鏈接觸發文件下載,幷包含一個數據表中,該數據表本身插入一個模態對話框。任何幫助讚賞。

+0

請仔細閱讀[問]和改善你的問題,請參見http://stackoverflow.com/help/on-topic – Kukeltje

+0

歡迎收看也點1,請包括一些你嘗試過什麼到目前爲止,以幫助你提高它 –

回答

0

我測試過這個方法,它的工作對我很好,但做一個完整的答案添加一些代碼,以瞭解是否有問題

public void downloaddoc(FileUploadEvent file) throws FileNotFoundException, TransformerConfigurationException, TransformerException { 
InputStream input = file.getFile().getInputstream(); 

ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); 
    setDownload(new DefaultStreamedContent(input, externalContext.getMimeType(file.getFile().getName(), file.getFile().getName())); 
} 

你可以閱讀更多的Primefaces Web Site

。希望幫助你。