public abstract class ValidationItem
extends java.lang.Object
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)
ValidationItem
s can be added to a ValidationGroup using
ValidationGroup.addItem(org.netbeans.validation.api.ui.ValidationItem, boolean)
.
Modifier and Type | Method and Description |
---|---|
Problem |
performValidation()
A request (to the simple-validation infrastructure) for revalidation of
the component(s) managed by this ValidationListener/ValidationGroup, updating
the
ValidationUI as necessary. |
void |
runWithValidationSuspended(java.lang.Runnable run)
Disable validation and invoke a runnable.
|
public final Problem performValidation()
A request (to the simple-validation infrastructure) for revalidation of
the component(s) managed by this ValidationListener/ValidationGroup, updating
the ValidationUI
as 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 ValidationListener
subclasses
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 to ValidationListener.performValidation(org.netbeans.validation.api.Problems)
will occur.
If this results in a Problem
, the ValidationUI
managed by this ValidationListener
(such as an error icon
decorating the UI-component) will be activated, indicating the Problem
to the user.
If this ValidationListener has been added to a ValidationGroup
,
the latter will update its ValidationUI
:s as well (unless there happens
to be a more severe Problem
somewhere else within that ValidationGroup
)
public final void runWithValidationSuspended(java.lang.Runnable run)
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.
run
- A runnable which makes changes to the contents of one
or more components in the UI which should not trigger validation