【问题标题】:How do you set the message for an ICEfaces ice:inputFile filename validation error?如何为 ICEfaces ice:inputFile 文件名验证错误设置消息?
【发布时间】:2011-03-31 18:39:38
【问题描述】:

设置: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 标签会显示以下(隐秘且对用户不利)错误:

文件名“halp_im_not_a_pdf.rtf”与文件名模式“.+\.pdf”不匹配

我如何用更好的东西替换消息?我尝试在网上搜索并在 ice:inputFile 上设置一个名为“converterMessage”的属性,但它们都不像通常那样工作。

谢谢。

【问题讨论】:

标签: java jsf icefaces messages


【解决方案1】:

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 以了解您可能想要替换的其他错误消息。

【讨论】:

    猜你喜欢
    • 2018-07-11
    • 1970-01-01
    • 2016-08-01
    • 1970-01-01
    • 2011-10-14
    • 1970-01-01
    • 2020-10-28
    • 1970-01-01
    • 2014-02-15
    相关资源
    最近更新 更多