I want to create a validator that works on multiple fields. Basically,
if one is entered the other two must be entered. If it set the validator
on any one field and it isn't entered, the validator is not run, so I must
put it on all three fields. Then I need to worry about if the error message
has already been set by a previous validator, among other things. In the
book Core JavaServer Faces, they mention the alternative approach below, but
I can't get it to work. No matter what I put in the value attribute, the
validator is not run. What do I need to do for "It is essential that you
supply some field value"?

Thanks,
Lance

==========================================================================

An alternative approach is to attach the validator to a hidden input field
that comes after all other fields on the form.

<h:inputHidden id="datecheck" validator="#{bb.validateDate}"
value="needed"/>

The hidden field is rendered as a hidden HTML input field. When the field
value is posted back, the validator kicks in. (It is essential that you
supply some field value. Otherwise, the component
value is never updated.) With this approach, the validation function is more
symmetrical since all other form components already have their local values
set.

Reply via email to