You can implement an IFormValidator. Alternatively you use a custom
IValidator which checks the current value of the optional field:
public class OptionalValidator<T> implements IValidator<T>
{
private FormComponent<?> optional;
private IValidator<T> validator;
public OptionalValidator(FormComponent<?> optional, IValidator<T>
validator)
{
this.optional = optional;
this.validator = validator;
}
@Override
public void validate(IValidatable<T> validatable)
{
if (!Strings.isEmpty(optional.getValue()))
{
validator.validate(validatable);
}
}
}
Sven
On 04/14/2013 10:28 AM, [email protected] wrote:
Hi,
i'd like to implement a "3-Field-Validator". This means if one optional field
in a form is set, two other fields become mandatory as well.
What's the best way to implement this?
My first thought was to use it IValidator, but this accepts just values of one
field - as far as i've understood
My second was to implement a validator method in the submit event of the
AjaxButton and to add some FeedbackMessages to the page in case of failure
Any other approaches?
Thx André
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]