开发者

How do you set the message for an ICEfaces ice:inputFile filename validation error?

Setup: ICEfaces 1.8.2, Java EE 5, JSF 1.2.

I'm using an ice:inputFile tag to allow the user to upload a PDF file, and an ice:messages tag to provide error feedback to the user:

<ice:inputFile fileNamePattern=".+\.pdf" uniqueFolder="false" uploadDirectory="#{FileController.fileUploadDirectory}" uploadDirectoryAbsolute="true" actionListener="#{FileController.uploadAct开发者_如何转开发ionListener}" submitOnUpload="preAndPostUpload" />
<!-- ... -->
<ice:messages />

If the user tries to upload a file whose name doesn't end with '.pdf', the ice:messages tag shows the following (cryptic and user-hostile) error:

The file name 'halp_im_not_a_pdf.rtf' does not match with the file name pattern '.+\.pdf'

How would I replace the message with something better? I've tried searching the Web and setting an attribute called 'converterMessage' on ice:inputFile, but neither of those worked like they usually do.

Thank you.


See http://www.icefaces.org/JForum/posts/list/9528.page#39677
You have to create a properties file, and in it define:

com.icesoft.faces.component.inputfile.INVALID_NAME_PATTERN=The file name \''{0}\'' does not match with the file name pattern \''{1}\''

See the messages.properties in ICEFaces for other error messages you may want to replace.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜