org.granite.client.validation.javafx
Class FormValidator

java.lang.Object
  extended by org.granite.client.validation.javafx.FormValidator

public class FormValidator
extends Object

Author:
William DRAI

Nested Class Summary
 class FormValidator.ChildChangeListener
           
 
Field Summary
protected  Map<javafx.scene.Node,javafx.beans.property.Property<?>> entityProperties
           
protected  Set<javafx.scene.Node> focusedOutOnce
           
protected  javafx.scene.Parent form
           
 Class<?>[] groups
          The validation groups to be used, as an array of Class names.
protected  Map<javafx.scene.Node,javafx.beans.property.Property<?>> inputProperties
           
protected  List<javafx.scene.Node> inputs
           
static String UNHANDLED_VIOLATIONS
           
protected  javafx.collections.ObservableList<ConstraintViolation<?>> unhandledViolations
           
 javafx.beans.property.BooleanProperty validateOnChangeProperty
          Should validation be done on the fly?
protected  List<ConstraintViolation<?>> violations
           
 
Constructor Summary
FormValidator()
           
FormValidator(TraversableResolver traversableResolver)
           
FormValidator(ValidatorFactory validatorFactory)
           
 
Method Summary
 javafx.scene.Parent getForm()
          The form component that contains inputs bound to the entity properties (may be a Form or any other Container subclass).
 List<ConstraintViolation<?>> getUnhandledViolations()
          Returns the unhandled violations of the last global validation as an array of ConstraintViolations.
 List<ConstraintViolation<?>> getViolations()
          Returns the result of the last global validation as an array of ConstraintViolations.
protected  void handleViolations(javafx.scene.Node input, Set<ConstraintViolation<Object>> violations)
           
 boolean isValidateOnChange()
           
 void setForm(javafx.scene.Parent form)
           
protected  void setupForm(javafx.scene.Parent form)
           
 void setValidateOnChange(boolean validateOnChange)
           
protected  void trackNode(javafx.scene.Node node)
           
protected  void untrackNode(javafx.scene.Node node)
           
 boolean validate(javafx.event.EventTarget entity)
           
protected  boolean validateValue(javafx.scene.Node input, boolean focusOut)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNHANDLED_VIOLATIONS

public static final String UNHANDLED_VIOLATIONS
See Also:
Constant Field Values

form

protected javafx.scene.Parent form

inputs

protected List<javafx.scene.Node> inputs

inputProperties

protected Map<javafx.scene.Node,javafx.beans.property.Property<?>> inputProperties

entityProperties

protected Map<javafx.scene.Node,javafx.beans.property.Property<?>> entityProperties

focusedOutOnce

protected Set<javafx.scene.Node> focusedOutOnce

violations

protected List<ConstraintViolation<?>> violations

unhandledViolations

protected javafx.collections.ObservableList<ConstraintViolation<?>> unhandledViolations

validateOnChangeProperty

public javafx.beans.property.BooleanProperty validateOnChangeProperty
Should validation be done on the fly? Otherwise, validation will be only done when an input loses focus. Default is true.


groups

public Class<?>[] groups
The validation groups to be used, as an array of Class names. Default is null, meaning that the Default group will be used.

Constructor Detail

FormValidator

public FormValidator()

FormValidator

public FormValidator(TraversableResolver traversableResolver)

FormValidator

public FormValidator(ValidatorFactory validatorFactory)
Method Detail

isValidateOnChange

public boolean isValidateOnChange()

setValidateOnChange

public void setValidateOnChange(boolean validateOnChange)

validate

public boolean validate(javafx.event.EventTarget entity)

getForm

public javafx.scene.Parent getForm()
The form component that contains inputs bound to the entity properties (may be a Form or any other Container subclass).


setForm

public void setForm(javafx.scene.Parent form)

getViolations

public List<ConstraintViolation<?>> getViolations()
Returns the result of the last global validation as an array of ConstraintViolations.

Returns:
the result of the last global validation as an array of ConstraintViolations.

getUnhandledViolations

public List<ConstraintViolation<?>> getUnhandledViolations()
Returns the unhandled violations of the last global validation as an array of ConstraintViolations. Unhandled violations are violations that couldn't be associated to any input during the last global validation (thus, they couldn't be displayed anywhere).

Returns:
the unhandled violations of the last global validation as an array of ConstraintViolations.

setupForm

protected void setupForm(javafx.scene.Parent form)

trackNode

protected void trackNode(javafx.scene.Node node)

untrackNode

protected void untrackNode(javafx.scene.Node node)

validateValue

protected boolean validateValue(javafx.scene.Node input,
                                boolean focusOut)

handleViolations

protected void handleViolations(javafx.scene.Node input,
                                Set<ConstraintViolation<Object>> violations)