Richfaces fileupload - perform name check on 'add'
I would like to perform a check on the name of a file being uploaded via richfaces fil开发者_运维问答eupload component. I would like to check this as soon as the user selects the file. A file with a wrong name, should not appear in the list, and an alert() should be called specifying the filename was not correct.
Is there a way to check the add event, and to interrupt it when the filename is not correct?
ypu can use onAdd function or in the richface you can use the filesubmit event in your ajax listener:
<rich:fileUpload fileUploadListener="#{fileUploadBean.listener}" id="upload" acceptedTypes="jpg, gif, png, bmp"
ontyperejected="alert('Only JPG, GIF, PNG and BMP files are accepted');" maxFilesQuantity="5">
<a4j:ajax event="filesubmit" execute="@none" render="info" />
Before uploading the file filesubmit event fires. So you can check what you want on there. Refer this article Richfaces HTML documentation.
It's possible but you would need to write your own JavaScript function to check that. You could use onupload event to call the function.
you can use onadd event, if you are using RF3.3
精彩评论