问题
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:
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.
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