如何在RichFaces 4 fileUpload组件中显示有关最大文件大小限制的消息 [英] How to display message about maximum file size restriction in RichFaces 4 fileUpload component
问题描述
我已经使用RichFaces 4.3实现了文件上传.文件上传可以正常工作,有关文件类型的警报也可以,但是有关最大文件大小限制的警报则不能.文件上传代码:
I have implemented a file upload using RichFaces 4.3. File upload works fine, alert about file types works fine, but alert about max file size restriction doesn't. File upload code:
<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>
设置上下文参数,并进行限制.但是不会显示警报消息.任何建议表示赞赏.
Context parameters are set up and restriction works. But alert message is not displayed. Any suggestion is appreciated.
更新
消息问题与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
.
推荐答案
您需要一种机制来显示fileUpload
生成的面部消息,例如:
You need a mechanism to show the faces messages generated by the fileUpload
, e.g.:
<rich:message for="bannerUpload" showDetail="true" ajaxRendered="true"/>
更新
根据错误文本"Load denied by X-Frame-Options: ...?rf_fu_uid=... does not permit framing."
,在我看来,有两种可能的原因:
According to the error text "Load denied by X-Frame-Options: ...?rf_fu_uid=... does not permit framing."
, to me it looks like there are two possible causes:
-
X-Frame-Options
标头具有值DENY
.将其更改为SAMEORIGIN
以允许为您的网站框架. -
X-Frame-Options
标头具有值SAMEORIGIN
,但是出于某种原因,fileUpload尝试将来自不同域的内容放入帧中.
X-Frame-Options
header has the valueDENY
. Change it toSAMEORIGIN
to allow framing for your site.X-Frame-Options
header has the valueSAMEORIGIN
, but for some reason fileUpload tries to put into a frame something from different domain.
两者都可以在Firebug的网络"标签上选中.
Both can be checked on the Network tab of Firebug.
这篇关于如何在RichFaces 4 fileUpload组件中显示有关最大文件大小限制的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!