I've tried posting about this on stackoverflow but without any luck, so lets try here instead.
Lately I've been trying to implement some proper validation of a form that I have in my application.
The form contains a datatable, that has several different input fields with custom validators on every row. Every field is being updated by AJAX like this:
Code: Select all
<p:calendar id="lineDeliveryDate" value="#{line.deliveryDate}" converter="localDateConverter" pattern="yyyy-MM-dd" mindate="#{dateHelper.today()}">
<f:validator binding="#{deliveryDateValidator}" />
<f:attribute name="line" value="#{line}" />
<p:ajax event="dateSelect" process="@this" delay="500" update="@form growlInfo @([id$=nextStepBtn])" listener="#{checkoutDeliveryDateController.saveLine(line)}" />
<p:ajax event="change" process="@this" delay="500" update="@form growlInfo @([id$=nextStepBtn])" listener="#{checkoutController.saveLine(line)}" />
</p:calendar>
Code: Select all
<h:commandButton value="#{messages['checkout.nextStep']}" id="nextStepBtn" disabled=" {facesContext.validationFailed}"
title="#{tooltip}">
<f:ajax execute="@this" />
</h:commandButton>
- Field 1 is updated with an invalid value.
Field 2 is updated with an invalid value.
Field 2 is updated with a valid value -> facesContext.validationFailed returns false, ignoring that field 1 is still invalid. This causes the nextbutton to be enabled, even though one field is invalid.
I have thought about processing @form in my AJAX-calls, but that will cause every single field to be validated with every AJAX-call, slowing down the page. I'm using Primefaces 6.
Any input is appreciated, Cheers.