Class Binding<T>
- Type Parameters:
T- the type of the value
Form, with the rules its value must meet.
Its validation has a check per requirement: first the converter's, if it has one, then one per rule, in the order
they were added. Every rule is tested at each validation, whether or not an earlier one failed. When the converter
rejects the field's text, the rules' checks are Check.Status.UNKNOWN. A rule that throws is a bug in the
rule: the exception goes to the FailureHandler, and the rule's check is Check.Status.UNKNOWN; an
Error is not caught. The binding is validated when it is bound, at each change of its component and at each
change of its property.
Its error, the requirement of the first check that isn't met, is shown on its component by the
ValidationFeedback while shown() is true, and hidden as soon as the binding has no error.
Every method is called on the EDT, and every subscription it makes belongs to the view's scope.
-
Method Summary
Modifier and TypeMethodDescriptionAdds a rule to this binding, whose check follows those of the rules added before.Adds the rules of a validator to this binding, in their order, after the rules added before.revalidateOn(Observable<?> other) Validates this binding again at each change of another observable, on the EDT, such as the property of another field that a rule compares the value with: before the change returns for a change made on the EDT, such as the user's change of that field, once the list has released its lock for one delivered by an observable list, and in a posted update for one made on another thread.shown()Returns whether this binding's error is shown:falseuntil the user changes the component orForm.validate()is called, thentruefor the binding's life.Returns whetherForm.validate()was called since the user last changed the component:falseuntil it is called, thentrueuntil the user changes the component.Returns the last validation of this binding.
-
Method Details
-
check
Adds a rule to this binding, whose check follows those of the rules added before.- Parameters:
rule- the rule- Returns:
- this binding
- Throws:
NullPointerException- ifruleisnull
-
check
Adds the rules of a validator to this binding, in their order, after the rules added before.- Parameters:
validator- the validator- Returns:
- this binding
- Throws:
NullPointerException- ifvalidatorisnull
-
revalidateOn
Validates this binding again at each change of another observable, on the EDT, such as the property of another field that a rule compares the value with: before the change returns for a change made on the EDT, such as the user's change of that field, once the list has released its lock for one delivered by an observable list, and in a posted update for one made on another thread. A change ofotheris not a user change of this binding's component: it doesn't changeshown()orvalidated().- Parameters:
other- the observable- Returns:
- this binding
- Throws:
NullPointerException- ifotherisnull
-
validation
Returns the last validation of this binding.- Returns:
- the validation
-
shown
Returns whether this binding's error is shown:falseuntil the user changes the component orForm.validate()is called, thentruefor the binding's life.- Returns:
- whether the error is shown
-
validated
Returns whetherForm.validate()was called since the user last changed the component:falseuntil it is called, thentrueuntil the user changes the component. A change of the property, or of an observable the binding revalidates on, doesn't change it. A view that lists the requirements uses it to show them as failed aftervalidate(), such as on OK, even for a value it otherwise shows as not yet checked.- Returns:
- whether the binding was validated since the user last changed the component
-