Reputation: 3957
I am using primefaces3.5 fileupload control. When I upload a wrong format file then it shows a error message "Wrong format etc". After that when I upload a correct format file then it uploads fine but does not remove the error message.
While searching I found this solution on primefaces forum but it is also not working.
How can I remove the error message on subsequent uploads?
Here is my code
<p:fileUpload id="fu"
allowTypes="/(\.|\/)(DOC|DOCX|doc|docx|ppt|pptx|xls|xlsx|pdf)$/"
onstart="loadingCursor();" oncomplete="simpleCursor();"
multiple="false" mode="advanced" sizeLimit="52428800"
showButtons="false"
fileUploadListener="#{documentInsertController.uploadPListener}"
label="Browse"
invalidSizeMessage="File size exceeds limit 45 MB "
value="#{documentInsertController.file}" auto="true"
invalidFileMessage="Invalid file type.Only doc,ppt,xls and pdf files allowed."
>
<h:message id="docMSG" for="fu"></h:message>
</p:fileUpload>
Upvotes: 3
Views: 6760
Reputation: 23413
Worked for me with PrimeFaces 3.5:
<script type="text/javascript">
$(document).ready(function () {
fileuplaod_wgt.buttonBar.find("button.cancel").bind("click", function (e) {
clearInvalidFileMsg();
});
});
function clearInvalidFileMsg() {
fileuplaod_wgt.uploadContent.find("tr.ui-state-error").remove();
}
</script>
And I've added widgetVar="fileuplaod_wgt"
in the p:fileUpload
. Then cancel
button works and removes invalid files.
It is not a permanent solution. Just a workaround until it will be fixed within PrimeFaces itself. Check: https://code.google.com/p/primefaces/issues/detail?id=3652
Upvotes: 1