Well, I like it when I can answer my question:
Here is the updated code:
<p:dialog appendToBody="true" id="importDevices" widgetVar="importDevicesDialogWidget" header="Import Devices" resizable="false" modal="true" onShow="centerDialog('#importDevicesDialog');"> <h:form id="importDevicesForm" enctype="multipart/form-data"> <h:panelGrid columns="1" cellpadding="5"> <p:fileUpload id="scriptUpload" widgetVar="importDevicesWidget" fileUploadListener="#{scriptUploadBean.handleFileUpload}" auto="true" label="Choose.." mode="advanced" update=":infoMessages" sizeLimit="8192" allowTypes="/(\.|\/)(txt)$/" onstart="clearInvalidFileMsg();$('#progress').show();" oncomplete="clearInvalidFileMsg();$('#progress').hide();importDevicesDialogWidget.hide()"/> <p:spacer height="10px;"/> <p:commandButton value="Cancel" action="javascript.void(0);" onclick="clearInvalidFileMsg();importDevicesDialogWidget.hide();"/> </h:panelGrid> </h:form> </p:dialog>
And here is an updated function that hides the progress panel and buttons, and also eliminates errors:
function clearInvalidFileMsg(){ if ($("#importDevicesForm").is(':visible')){ importDevicesWidget.uploadContent.find("tr.ui-state-error").remove(); importDevicesWidget.uploadContent.find("td.progress").remove(); importDevicesWidget.uploadContent.find("td.start").remove(); importDevicesWidget.uploadContent.find("td.cancel").remove(); } }
source share