I have the following input field:
If the field is empty it w
You've hit an oversight in JSF. The validator
is wrapped in a MethodExpressionValidator which according to the source of its validate() method indeed skips validation when the value is null
.
if (value != null) {
try {
ELContext elContext = context.getELContext();
methodExpression.invoke(elContext, new Object[]{context, component, value});
...
This is not considering the new JSF 2.0 javax.faces.VALIDATE_EMPTY_FIELDS
context parameter which defaults to true
. It should actually be doing the same as UIInput#validate().
if (!isEmpty(newValue) || validateEmptyFields(context)) {
try {
ELContext elContext = context.getELContext();
methodExpression.invoke(elContext, new Object[]{context, component, value});
...
This has already been reported as Mojarra issue 1508. I've voted it and added a new comment to wake them up.