【问题标题】:Show message only when there are no messages for other components仅当没有其他组件的消息时才显示消息
【发布时间】:2013-04-04 01:26:03
【问题描述】:

验证表单时显示 3 条消息,类似这样:

<p:message id="msgCity1"  for="city1" styleClass="required" display="text" />
<p:message id="msgCity2"  for="city2" styleClass="required" display="text" />
<p:message id="msgCountry"  for="msgCountry" styleClass="required" display="text" />

第一个(msgCity1)和第二个(msgCity2)消息在事件(keyup)上进行验证 最后一个是在服务器端验证,我想显示最后一条消息(msgCountry),如果前两条消息的验证正常,我的意思是如果消息为空,

为此,我想在最后一条消息上使用渲染,但我不知道如何在 xhtml 中获取前 2 条消息的值

【问题讨论】:

    标签: forms validation jsf-2 user-interface primefaces


    【解决方案1】:

    与其直接挂钩UIInput#isValid(),不如挂钩输入消息的存在。

    例如

    <h:inputText id="city1" binding="#{city1}" ... />
    <h:inputText id="city2" binding="#{city2}" ... />
    ...
    <p:message for="msgCountry" ... rendered="#{city1.valid and city2.valid}" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 2020-03-31
      相关资源
      最近更新 更多