View Javadoc

1   /*
2    * Copyright 2006-2016 The JGUIraffe Team.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License")
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.jguiraffe.gui.builder.window.ctrl;
17  
18  /**
19   * <p>
20   * Definition of an interface for objects that can trigger the validation of a
21   * form.
22   * </p>
23   * <p>
24   * Validation of user input can make sense at different points of time, for
25   * instance only when the user hits the OK button, after an input field was
26   * left, or even while typing into an input field. It is up to a specific
27   * application to decide when validation should be performed. The user should
28   * get an early feedback about errors in the data entered, but on the other hand
29   * being overwhelmed by a multitude of validation error messages does not
30   * improve the usability of the software either.
31   * </p>
32   * <p>
33   * Because there are many different approaches to this problem a
34   * {@link FormController} does not determine itself when to
35   * initiate a validation operation, but delegates this task to a
36   * {@code FormValidationTrigger} implementation. So it is possible to
37   * choose the validation strategy dynamically.
38   * </p>
39   * <p>
40   * This interface only defines an initialization method. The idea is that a
41   * concrete implementation registers itself as event listener for the
42   * corresponding events. When it receives an event that should cause a
43   * validation, it can trigger the controller. This approach frees the controller
44   * from having to poll the trigger on a regular basis.
45   * </p>
46   *
47   * @author Oliver Heger
48   * @version $Id: FormValidationTrigger.java 205 2012-01-29 18:29:57Z oheger $
49   */
50  public interface FormValidationTrigger
51  {
52      /**
53       * Initializes this validation trigger and registers the associated form
54       * controller. An implementation can access the controller and all its
55       * dependent objects to establish a mechanism so that it gets notified when
56       * a validation is to be performed. (It will probably register itself as
57       * event listener on some or all of the form's components.) The reference to
58       * the form controller should probably be saved so a validation can be
59       * initiated.
60       *
61       * @param controller the associated form controller
62       */
63      void initTrigger(FormController controller);
64  }