How to display message about maximum file size restriction in RichFaces 4 fileUpload component

泪湿孤枕 提交于 2019-12-08 13:13:04

问题


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.

UPDATE

Problem with message is related to fileupload.js.jsf line 213.
Error message in Firebug: Load denied by X-Frame-Options: ...?rf_fu_uid=... does not permit framing. and Error: Permission denied to access property 'document' var contentDocument = event.target.contentWindow.document.


回答1:


You need a mechanism to show the faces messages generated by the fileUpload, e.g.:

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

UPDATE

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:

  1. X-Frame-Options header has the value DENY. Change it to SAMEORIGIN to allow framing for your site.
  2. X-Frame-Options header has the value SAMEORIGIN, but for some reason fileUpload tries to put into a frame something from different domain.

Both can be checked on the Network tab of Firebug.



来源:https://stackoverflow.com/questions/20292425/how-to-display-message-about-maximum-file-size-restriction-in-richfaces-4-fileup

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!