Class ValidationItem
- Direct Known Subclasses:
ValidationGroup, ValidationListener
ValidationGroup and ValidationListener, providing a common API
for forcing revalidation of the managed UI component or components, see performValidation(),
and for temporarily suspending validation, see
runWithValidationSuspended(java.lang.Runnable)
ValidationItems can be added to a ValidationGroup using
ValidationGroup.addItem(org.netbeans.validation.api.ui.ValidationItem, boolean).
- Author:
- Tim Boudreau, Hugo Heden
-
Method Summary
Modifier and TypeMethodDescriptionfinal ProblemA request (to the simple-validation infrastructure) for revalidation of the component(s) managed by this ValidationListener/ValidationGroup, updating theValidationUIas necessary.final voidDisable validation and invoke a runnable.
-
Method Details
-
performValidation
A request (to the simple-validation infrastructure) for revalidation of the component(s) managed by this ValidationListener/ValidationGroup, updating the
ValidationUIas necessary.This method can be called by client code (i.e non-subclasses), to manually request revalidation -- a "refresh". This can be useful if custom ValidationListeners are used that rely not only on the state of the managed component, but also on outside state that the listener does not know about
More typically, this method is called by
ValidationListenersubclasses to let the simple-validation infrastructure know that the user has interacted with the UI-component in a way that makes revalidation needed.This will initiate the validation logic (unless the validation is suspended, see
runWithValidationSuspended(java.lang.Runnable): A call toValidationListener.performValidation(org.netbeans.validation.api.Problems)will occur.If this results in a
Problem, theValidationUImanaged by thisValidationListener(such as an error icon decorating the UI-component) will be activated, indicating theProblemto the user.If this ValidationListener has been added to a
ValidationGroup, the latter will update itsValidationUI:s as well (unless there happens to be a more severeProblemsomewhere else within thatValidationGroup)- Returns:
- The lead problem of the ValidationItem, null if there is no Problem
-
runWithValidationSuspended
Disable validation and invoke a runnable. This method is useful in UIs where a change in one component can trigger changes in another component, and you do not want validation to be triggered because a component was programmatically updated.For example, say you have a dialog that lets you create a new Servlet source file. As the user types the servlet name, web.xml entries are updated to match, and these are also in fields in the same dialog. Since the updated web.xml entries are being programmatically (and presumably correctly) generated, those changes should not trigger a useless validation run. Wrap such generation code in a Runnable and pass it to this method when making programmatic changes to the contents of the UI.
The runnable is run synchronously, but no changes made to components while the runnable is running will trigger validation.
When the last runnable exits, validateAll(null) will be called to run validation against the entire newly updated UI.
This method is reentrant - a call to updateComponents can trigger another call to updateComponents without triggering multiple calls to validateAll() on each Runnable's exit.
- Parameters:
run- A runnable which makes changes to the contents of one or more components in the UI which should not trigger validation
-