I tried to set a calendar as invalid from the Java bean. The code is:
HtmlInputText htmlInput = (HtmlInputText) elem;
String classes = htmlInput.getStyleClass();
String newClasses = classes + " ui-state-error";
htmlInput.setStyleClass(newClasses);
UIInput input = (UIInput) elem;
input.setValid(false);
elem
is the calendar. The class is NOT displayed in the browser inspector.
In theory, input.setValid(false);
should be sufficient... Maybe the JS of p:calendar
is doing something wrong?
The element is:
<p:calendar
value="#{bean.val}"
id="x"
locale="it"
showOtherMonths="true"
pattern="dd/MM/yyyy"
navigator="true"
/>
I use Primefaces 3.4.1 with Mojarra 2.1.7