【问题标题】:JBoss Richfaces: How to provide a different validation message to rich:calendar from within the xhtml implementation?JBoss Richfaces:如何在 xhtml 实现中向 rich:calendar 提供不同的验证消息?
【发布时间】:2011-06-25 18:12:51
【问题描述】:

rich:calendar 的默认实现在这样使用时呈现消息“Value must be a date”,并且用户输入了无效的日期,例如“2011 年 13 月 13 日”。

<h:column>  
  <f:facet name="header">Opt-out Date</f:facet>
  <rich:calendar datePattern="MM/dd/yyyy" enableManualInput="true" value="#{dtl.withdDt}"  />
</h:column>

标签默认从 messages_en.properties 中提取这个键 javax.faces.converter.DateTimeConverter.DATE=Value 必须是日期

我希望消息是'选择退出日期必须是一个日期。'

尝试 #1 失败:

   <h:column>   
      <f:facet name="header">Opt-out Date</f:facet>
      <rich:calendar validatorMessage="Opt-out Date must be a date." datePattern="MM/dd/yyyy" enableManualInput="true" value="#{dtl.withdDt}"  />
    </h:column>

第 2 次尝试失败 创建属性文件条目:

validate.dateEntry={0} must be a date.

然后引用它:

<rich:calendar validatorMessage="validate.dateEntry" label="Opt-Out Date" datePattern="MM/dd/yyyy" enableManualInput="true" value="#{dtl.withdDt}" />

尝试 #3 失败

<rich:calendar validatorMessage="#{statusMessages.addToControlFromResourceBundle('Opt in Date',validate.dateEntry)}" label="Opt Out Date" datePattern="MM/dd/yyyy" enableManualInput="true" value="#{dtl.withdDt}" />

我做出了错误的假设或我没有理解的概念。指导非常感谢。

【问题讨论】:

    标签: java jsf jakarta-ee richfaces


    【解决方案1】:

    这是一个转换错误,而不是验证错误。使用converterMessage,而不是validatorMessage

    【讨论】:

    • 谢谢。传入参数有技巧吗?类似于:converterMessage="#{messages['validate.dateEntry'], 'Opt-in Date'}"
    猜你喜欢
    • 1970-01-01
    • 2012-04-22
    • 1970-01-01
    • 2017-04-08
    • 2019-05-21
    • 2014-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多