I have a bean validation according to:
@Min(value = 0)
@Max(value = 1000000)
private int kilometres;
In my facelet I have:
<p:messages autoUpdate="true" showDetail="true" showSummary="true" />
<p:outputLabel for="kilometres" value="Kilometres" />
<p:inputText id="kilometres" value="#{bean.vehicle.kilometres}">
<p:ajax event="change" />
</p:inputText>
When i have this it works fine, except that all messages for all field ids will be shown. I would like to specify for each field, like this:
<p:messages for="kilometres" autoUpdate="true" showDetail="true" showSummary="true" />
However, when I add the for=”kilometres” option, then no validation messages is shown. Have I missed something or is it a bug?
Best regards
Use the
<p:message/>component to show validation messages for each input component separately:Showcase: AJAX – Validations
UPDATE
In order to show multiple message for a given component (with
p:messages) you need to specify the relevant component ID infor="kilometres"and in your backing bean too: