Primefaces clientValidator message not displayed

旧街凉风 提交于 2019-12-11 09:27:59

问题


I tried to use Primefaces

<p:clientValidator> 

along with the

<p:message> 

but without any success. The message is simply not displayed. Here is a snippet of my .xhtml:

<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>

Can anybody tell me what I'm doing wrong? I also tried with

<p:messages autoUpdate="true" /> 

instead of

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

and it worked but I prefer a dedicated message instead of global messages.


回答1:


PrimeFaces client-side validation is disabled by default and adding the following global parameter is required to enable it:

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


来源:https://stackoverflow.com/questions/25740225/primefaces-clientvalidator-message-not-displayed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!