+1
This is one of the thinks I don“t like in the spec. IMO this has to be
changed for the 1.2 release. You should send this mail to
[EMAIL PROTECTED] They should simple call the validator even if
the value is empty or null to let the validator choose what happens.
Regards,
Mathias
Marc Fonteijn schrieb:
I'm looking for ways to assign a specific error message for required
fields. Setting the javax.faces.component.UIInput.REQUIRED isn't a
solution because I want a specific message for different fields.
I thought of implementing an custom validator (method) and doing my own
"required" check instead of using the "required=true" tag.
Unfortunately this is stated in section 3.5.5 in the JSF Specification
1.1:
"Unless otherwise specified, components with a null local value cause
the validation checking by this Validator to be skipped. If a component
should be required to have a non-null value, a component attribute with
the name required and the value true must be added to the component in
order to enforce this rule."
My conclusion is that the only way to enable this behaviour whould be
to overwrite the validate method in UIInput in an custom component. You
can see what that leads to, you'd have to make a custom implementation
of every component that extends UIInput.
Real solutions to this issue:
- Make the default validation behaviour of UIInput optional in order to
be able to write a custom validator that does the empty/null checking.
- Implement an additional attribute on UIInput "requiredMessage=....".
Did I miss an alternative solution?
Is this a flaw in the specification?
Marc.