Class FormValidationTriggerFocus
- java.lang.Object
-
- net.sf.jguiraffe.gui.builder.window.ctrl.FormValidationTriggerFocus
-
- All Implemented Interfaces:
EventListener,FormEventListener,FormFocusListener,FormValidationTrigger
public class FormValidationTriggerFocus extends Object implements FormValidationTrigger, FormFocusListener
A specialized
FormValidationTriggerimplementation that triggers a validation operation whenever the user leaves an input field.This validation trigger implementation registers itself as focus listener on all input components of the form to monitor. Whenever it receives a focus lost event, it triggers a validation operation.
This way the user gets fast feedback about invalid input. Invalid fields can be marked while editing the form, and fresh validation error messages can be displayed. Because validation happens only if the user switches to another input field, the number of validations (a UI updates related to validation) is limited. So this
FormValidationTriggeris a good compromise between real-time validation feedback and annoying the user with permanent validation messages.Implementation note: This class is not thread-safe. An instance should be associated with a single
FormControlleronly and not be reused.- Version:
- $Id: FormValidationTriggerFocus.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description FormValidationTriggerFocus()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfocusGained(FormFocusEvent e)Notifies this object that an input component gained focus.voidfocusLost(FormFocusEvent e)Notifies this object that an input component lost focus.FormControllergetFormController()Returns a reference to the associatedFormController.voidinitTrigger(FormController controller)Initializes thisFormValidationTrigger.
-
-
-
Method Detail
-
getFormController
public final FormController getFormController()
Returns a reference to the associatedFormController.- Returns:
- the
FormController
-
initTrigger
public void initTrigger(FormController controller)
Initializes thisFormValidationTrigger. This implementation stores theFormControllerreference and registers itself as global focus listener. Thus it can intercept every change in the focus of the associated input form.- Specified by:
initTriggerin interfaceFormValidationTrigger- Parameters:
controller- theFormController
-
focusGained
public void focusGained(FormFocusEvent e)
Notifies this object that an input component gained focus. This implementation does nothing.- Specified by:
focusGainedin interfaceFormFocusListener- Parameters:
e- the focus event
-
focusLost
public void focusLost(FormFocusEvent e)
Notifies this object that an input component lost focus. This implementation triggers theFormControllerto perform another validation.- Specified by:
focusLostin interfaceFormFocusListener- Parameters:
e- the focus event
-
-