3

我正在使用 primefaces3.5 文件上传控件。当我上传格式错误的文件时,它会显示错误消息“格式错误等”。之后,当我上传正确格式的文件时,它可以正常上传,但不会删除错误消息。
在搜索时,我在 primefaces 论坛上找到了这个解决方案,但它也不起作用。

如何删除后续上传的错误消息?

这是我的代码

<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>
4

1 回答 1

1

使用 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>

而且我已经widgetVar="fileuplaod_wgt"p:fileUpload. 然后cancel按钮起作用并删除无效文件。

这不是一个永久的解决方案。只是一种解决方法,直到它在 PrimeFaces 本身中得到修复。检查:https ://code.google.com/p/primefaces/issues/detail?id=3652

于 2013-05-31T08:27:33.553 回答