1
戰略p:fileDownload
與對話與裝載策略號碼:fileDownload與對話,並加載狀態
我試圖做一個加載條開始文件的下載之後。我的下載按鈕是這樣的:
<p:commandButton id="btnFirstType"
styleClass="bt_princ"
value="Download File"
onclick="loading.show()"
ajax="false">
<p:fileDownload value="#{mbean.myFile}"/>
</p:commandButton>
<p:dialog modal="true"
widgetVar="loading"
header="Status"
draggable="false"
closable="false">
<p:graphicImage value="/loading.gif" />
</p:dialog>
我的MBean是這樣的:
public StreamedContent getMyFile(){
return this.getReport(Type.CSV); //I assure this works, debugged...
}
問題是,點擊下載按鈕後,如果我開始加載對話框,下載未occurr。 我想過使用p:poll
來檢查一個布爾變量,所以我知道什麼時候文件已經生成,所以我可以在點擊按鈕後顯示對話框(例如使用JavaScript設置setTimeout
),但這可能是我關於整個事情的錯誤發生。任何其他建議?
PS1:輪詢停止工作的文件下載後,所以我不知道什麼時候關閉dialod
PS2:我使用Primefaces 2.2,不能更新。
PS3:找到this解決方法,但'它會'在版本3,所以我不能使用它。