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
FormValidationTrigger
implementation 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
FormValidationTrigger
is 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
FormController
only 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 void
focusGained(FormFocusEvent e)
Notifies this object that an input component gained focus.void
focusLost(FormFocusEvent e)
Notifies this object that an input component lost focus.FormController
getFormController()
Returns a reference to the associatedFormController
.void
initTrigger(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 theFormController
reference and registers itself as global focus listener. Thus it can intercept every change in the focus of the associated input form.- Specified by:
initTrigger
in 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:
focusGained
in interfaceFormFocusListener
- Parameters:
e
- the focus event
-
focusLost
public void focusLost(FormFocusEvent e)
Notifies this object that an input component lost focus. This implementation triggers theFormController
to perform another validation.- Specified by:
focusLost
in interfaceFormFocusListener
- Parameters:
e
- the focus event
-
-