[英]How to Show Widget while p:fileUpload is in progress
我正在使用這個fileUpload從Excel工作表上傳文檔。
<h:form id="leForm2" enctype="multipart/form-data">
<p:fileUpload
mode="advanced" showButtons="FALSE"
label="{messages['upload.xls']}"
fileUploadListener="#{bean.handleFileUpload}"
id="uploadCargaMasiva" update="messages3, :tabs:formTab2:documentoList" auto="true"
allowTypes="/(\.|\/)(xls|xlsx)$/"/>
<p:growl id="messages3" escape="true" sticky="false"
lifetime="800" showDetail="false" />
</h:form>
這按預期工作。 我的問題是,在上傳過程中,我需要顯示ap:Dialog,而我找不到這樣做的方法。
這是我的對話框:
<p:dialog widgetVar="statusDialog" modal="true" draggable="false" closable="false" resizable="false">
<p:graphicImage value="/images/ajaxloadingbar.gif" />
</p:dialog>
我不知道怎么稱呼它或在:(。有什么建議嗎?
<h:form id="leForm2" enctype="multipart/form-data">
<p:fileUpload
mode="advanced" showButtons="FALSE"
label="{messages['upload.xls']}"
fileUploadListener="#{bean.handleFileUpload}"
id="uploadCargaMasiva" update="messages3, :tabs:formTab2:documentoList" auto="true" onstart="statusDialog.show()"
allowTypes="/(\.|\/)(xls|xlsx)$/"/>
<p:growl id="messages3" escape="true" sticky="false"
lifetime="800" showDetail="false" />
</h:form>
在bean.java中,我在handleFileUpload的末尾添加了這一行:
RequestContext.getCurrentInstance().execute("widgetHide()");
widgetHide是一個JS函數:
<script type="text/javascript">
function widgetHide()
{
statusDialog.hide();
}
</script>
如所建議的,onstart和oncomplete應該可以解決問題,但是由於某些原因,oncomplete無法正常工作。 因此,我必須執行此遍歷才能使其正常運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.