[英]How to Show Widget while p:fileUpload is in progress
I'm using this fileUpload to upload documents from an Excel sheet. 我正在使用这个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>
This works as expected. 这按预期工作。 My issue is that I need to show ap:Dialog while the upload is in progress, and I can't find the way of doing this. 我的问题是,在上传过程中,我需要显示ap:Dialog,而我找不到这样做的方法。
This is my dialog: 这是我的对话框:
<p:dialog widgetVar="statusDialog" modal="true" draggable="false" closable="false" resizable="false">
<p:graphicImage value="/images/ajaxloadingbar.gif" />
</p:dialog>
I don't know how to call it or where :(. Any suggestions? 我不知道怎么称呼它或在:(。有什么建议吗?
<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>
In the bean.java I added this line at the end of handleFileUpload: 在bean.java中,我在handleFileUpload的末尾添加了这一行:
RequestContext.getCurrentInstance().execute("widgetHide()");
widgetHide is a JS function: widgetHide是一个JS函数:
<script type="text/javascript">
function widgetHide()
{
statusDialog.hide();
}
</script>
As was suggested, onstart and oncomplete shoud do the trick, but for some reason oncomplete wasn't working . 如所建议的,onstart和oncomplete应该可以解决问题,但是由于某些原因,oncomplete无法正常工作。 So I had to do this walkaround to make it work. 因此,我必须执行此遍历才能使其正常运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.