如何在RichFaces 4 fileUpload组件中显示有关最大文件大小限制的消息

时间:2013-11-29 19:42:13

标签: jsf-2 richfaces

我已使用RichFaces 4.3实现了文件上传。文件上传工作正常,关于文件类型的警报工作正常,但关于最大文件大小限制的警报不起作用。文件上传代码:

<rich:fileUpload id="bannerUpload"
    fileUploadListener="#{bean.bannerListener}"
    acceptedTypes="png, gif, jpg, jpeg"
    ontyperejected="alert('#{msg.bannerFormatRestriction}');"
    maxFilesQuantity="1"
    sizeExceededLabel="File size is restricted. Max allowed size is 1 MB."
    serverErrorLabel="File was not uploaded. Please try again."
    addLabel="Select image for banner">
</rich:fileUpload>

设置了上下文参数并且限制有效。但是不显示警报消息。任何建议都表示赞赏。

更新

邮件问题与fileupload.js.jsf line 213有关。
Firebug中的错误讯息:Load denied by X-Frame-Options: ...?rf_fu_uid=... does not permit framing.Error: Permission denied to access property 'document' var contentDocument = event.target.contentWindow.document

1 个答案:

答案 0 :(得分:1)

您需要一种机制来显示由fileUpload生成的面部消息,例如:

<rich:message for="bannerUpload" showDetail="true" ajaxRendered="true"/> 

<强>更新

根据错误文本"Load denied by X-Frame-Options: ...?rf_fu_uid=... does not permit framing.",对我来说,看起来有两种可能的原因:

  1. X-Frame-Options标头的值为DENY。将其更改为SAMEORIGIN以允许您的网站框架。
  2. X-Frame-Options标头的值为SAMEORIGIN,但由于某种原因,fileUpload会尝试将来自不同域的内容放入框架中。
  3. 可以在Firebug的“网络”选项卡上查看两者。

相关问题