Interface FormValidationTrigger

  • All Known Implementing Classes:
    FormValidationTriggerFocus, FormValidationTriggerNone

    public interface FormValidationTrigger

    Definition of an interface for objects that can trigger the validation of a form.

    Validation of user input can make sense at different points of time, for instance only when the user hits the OK button, after an input field was left, or even while typing into an input field. It is up to a specific application to decide when validation should be performed. The user should get an early feedback about errors in the data entered, but on the other hand being overwhelmed by a multitude of validation error messages does not improve the usability of the software either.

    Because there are many different approaches to this problem a FormController does not determine itself when to initiate a validation operation, but delegates this task to a FormValidationTrigger implementation. So it is possible to choose the validation strategy dynamically.

    This interface only defines an initialization method. The idea is that a concrete implementation registers itself as event listener for the corresponding events. When it receives an event that should cause a validation, it can trigger the controller. This approach frees the controller from having to poll the trigger on a regular basis.

    Version:
    $Id: FormValidationTrigger.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Method Detail

      • initTrigger

        void initTrigger​(FormController controller)
        Initializes this validation trigger and registers the associated form controller. An implementation can access the controller and all its dependent objects to establish a mechanism so that it gets notified when a validation is to be performed. (It will probably register itself as event listener on some or all of the form's components.) The reference to the form controller should probably be saved so a validation can be initiated.
        Parameters:
        controller - the associated form controller