【问题标题】:Primefaces clientValidator message not displayedPrimefaces clientValidator 消息未显示
【发布时间】:2014-09-09 08:45:58
【问题描述】:

我尝试使用 Primefaces

<p:clientValidator> 

随着

<p:message> 

但没有任何成功。该消息根本不显示。这是我的 .xhtml 的 sn-p:

<h:form id="systemLogTable">
...
<h:panelGroup>
    <p:inputText id="last-input" value="#{lazyLogsDataModel.lastTime}" size="10" disabled="#{lazyLogsDataModel.timeFilteringOption != 2}">
        <p:ajax event="keyup" update="logsTable" />
        <p:clientValidator event="keyup" update="msg"/>
    </p:inputText>
    <h:selectOneMenu id="selectLastType" value="#{lazyLogsDataModel.lastUnit}" disabled="#{lazyLogsDataModel.timeFilteringOption != 2}">
        <f:selectItem itemLabel="Days" itemValue="0"/>
        <f:selectItem itemLabel="Hours" itemValue="1" />
        <f:selectItem itemLabel="Minutes" itemValue="2" />
        <a4j:ajax event="change" render="systemLogTable" />
    </h:selectOneMenu>
</h:panelGroup>
<p:message id="msg" for="last-input"/>
...
</h:form>

谁能告诉我我做错了什么? 我也尝试过

<p:messages autoUpdate="true" /> 

而不是

<p:message for="last-input" /> 

它有效,但我更喜欢专用消息而不是全局消息。

【问题讨论】:

  • 您需要在 inputText 和 selectOneMenu 上包含一个验证器。另外,您是否通过添加“primefaces.CLIENT_SIDE_VALIDATION”全局上下文参数来启用客户端验证?
  • @codeturner 上下文参数解决了它。谢谢!

标签: jsf jsf-2 primefaces client-side-validation


【解决方案1】:

PrimeFaces 客户端验证默认处于禁用状态,需要添加以下全局参数才能启用它:

<context-param>
 <param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name>
 <param-value>true</param-value>
</context-param>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-03
    • 2013-12-27
    • 1970-01-01
    • 1970-01-01
    • 2012-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多