设置:ICEfaces 1.8.2、Java EE 5、JSF 1.2。
我使用ice:inputFile标签来允许用户上传PDF文件,并使用ice:messages标签来向用户提供错误反馈:
<ice:inputFile fileNamePattern=".+\.pdf" uniqueFolder="false" uploadDirectory="#{FileController.fileUploadDirectory}" uploadDirectoryAbsolute="true" actionListener="#{FileController.uploadActionListener}" submitOnUpload="preAndPostUpload" />
<!-- ... -->
<ice:messages />
如果用户尝试上传名称不以“.pdf”结尾的文件,ice:messages 标记会显示以下(神秘且对用户不利的)错误:
The file name 'halp_im_not_a_pdf.rtf' does not match with the file name pattern '.+\.pdf'
如何用更好的内容替换该消息?我尝试在网络上搜索并在ice:inputFile上设置一个名为“converterMessage”的属性,但是这些都没有像平常那样工作。
谢谢。
最佳答案
参见http://www.icefaces.org/JForum/posts/list/9528.page#39677
您必须创建一个属性文件,并在其中定义:
com.icesoft.faces.component.inputfile.INVALID_NAME_PATTERN=The file name \''{0}\'' does not match with the file name pattern \''{1}\''
请参阅 ICEFaces 中的 messages.properties,了解您可能想要替换的其他错误消息。
关于java - 如何设置 ICEfaces 冰 :inputFile filename validation error? 的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3516151/