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