【发布时间】: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”的属性,但它们都不像通常那样工作。
谢谢。
【问题讨论】:
-
您可以在支持 bean 中使用验证并在上传操作中相应地设置消息。此链接可能有用 - facestutorials.icefaces.org/tutorial/validators-tutorial.html
标签: java jsf icefaces messages