java.lang.Object
com.dlsc.formsfx.model.structure.Form

public class Form
extends Object
A form is the containing unit for sections and elements and is used to bring structure to form data. It also acts as a proxy to some properties of the contained data, such as validity or changes.
Author:
Sacha Schmid, Rinesch Murugathas
  • Property Summary

    Properties 
    Type Property Description
    javafx.beans.property.BooleanProperty changed  
    javafx.beans.property.BooleanProperty persistable  
    javafx.beans.property.StringProperty title
    The title acts as a description for the form.
    javafx.beans.property.BooleanProperty valid
    The form acts as a proxy for its contained sections' changed and valid properties.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected javafx.beans.property.BooleanProperty changed  
    protected List<Group> groups  
    protected Runnable localeChangeListener  
    protected javafx.beans.property.BooleanProperty persistable  
    protected javafx.beans.property.StringProperty title
    The title acts as a description for the form.
    protected javafx.beans.property.StringProperty titleKey  
    protected javafx.beans.property.ObjectProperty<TranslationService> translationService
    A form can optionally have a translation service.
    protected javafx.beans.property.BooleanProperty valid
    The form acts as a proxy for its contained sections' changed and valid properties.
  • Method Summary

    Modifier and Type Method Description
    Form addEventHandler​(javafx.event.EventType<FormEvent> eventType, javafx.event.EventHandler<? super FormEvent> eventHandler)
    Registers an event handler to this form.
    Form binding​(BindingMode newValue)
    Changes the way field values are bound to external properties.
    javafx.beans.property.BooleanProperty changedProperty()  
    protected void fireEvent​(FormEvent event)  
    List<Element> getElements()  
    List<Field> getFields()  
    List<Group> getGroups()  
    String getTitle()
    Gets the value of the property title.
    boolean hasChanged()  
    Form i18n​(TranslationService newValue)
    Sets the translation service property of the current form.
    boolean isI18N()  
    boolean isPersistable()
    Gets the value of the property persistable.
    boolean isValid()
    Gets the value of the property valid.
    static Form of​(Group... sections)
    Creates a new form containing the given sections.
    void persist()
    Persists the values for all elements contained in this form's groups.
    javafx.beans.property.BooleanProperty persistableProperty()  
    Form removeEventHandler​(javafx.event.EventType<FormEvent> eventType, javafx.event.EventHandler<? super FormEvent> eventHandler)
    Unregisters a previously registered event handler from this form.
    void reset()
    Resets the values for all elements contained in this form's groups.
    protected void setChangedProperty()
    Sets this form's changed property based on its contained groups' changed properties.
    protected void setPersistableProperty()
    Sets this form's persistable property based on its contained groups' persistable properties.
    protected void setValidProperty()
    Sets this form's valid property based on its contained groups' changed properties.
    Form title​(String newValue)
    Sets the title property of the current form.
    javafx.beans.property.StringProperty titleProperty()
    The title acts as a description for the form.
    protected void translate()
    This internal method is used as a callback for when the translation service or its locale changes.
    javafx.beans.property.BooleanProperty validProperty()
    The form acts as a proxy for its contained sections' changed and valid properties.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Property Details

    • changed

      public javafx.beans.property.BooleanProperty changedProperty
    • valid

      public javafx.beans.property.BooleanProperty validProperty
      The form acts as a proxy for its contained sections' changed and valid properties.
      See Also:
      isValid()
    • persistable

      public javafx.beans.property.BooleanProperty persistableProperty
      See Also:
      isPersistable()
    • title

      public javafx.beans.property.StringProperty titleProperty
      The title acts as a description for the form. This property is translatable if a TranslationService is set.
      See Also:
      getTitle()
  • Field Details

    • groups

      protected final List<Group> groups
    • title

      protected final javafx.beans.property.StringProperty title
      The title acts as a description for the form. This property is translatable if a TranslationService is set.
    • titleKey

      protected final javafx.beans.property.StringProperty titleKey
    • valid

      protected final javafx.beans.property.BooleanProperty valid
      The form acts as a proxy for its contained sections' changed and valid properties.
    • changed

      protected final javafx.beans.property.BooleanProperty changed
    • persistable

      protected final javafx.beans.property.BooleanProperty persistable
    • translationService

      protected final javafx.beans.property.ObjectProperty<TranslationService> translationService
      A form can optionally have a translation service. This service is used to translate displayed values into multiple locales. The form registers itself as a listener on the translation service to handle locale changes.
      See Also:
      TranslationService
    • localeChangeListener

      protected final Runnable localeChangeListener
  • Method Details

    • of

      public static Form of​(Group... sections)
      Creates a new form containing the given sections.
      Parameters:
      sections - The sections to be included in the form.
      Returns:
      Returns a new Form.
    • title

      public Form title​(String newValue)
      Sets the title property of the current form.
      Parameters:
      newValue - The new value for the title property. This can be the title itself or a key that is then used for translation.
      Returns:
      Returns the current form to allow for chaining.
      See Also:
      TranslationService
    • i18n

      public Form i18n​(TranslationService newValue)
      Sets the translation service property of the current form.
      Parameters:
      newValue - The new value for the translation service property.
      Returns:
      Returns the current form to allow for chaining.
    • binding

      public Form binding​(BindingMode newValue)
      Changes the way field values are bound to external properties.
      Parameters:
      newValue - The new mode for handling external bindings.
      Returns:
      Returns the current form to allow for chaining.
      See Also:
      BindingMode
    • translate

      protected void translate()
      This internal method is used as a callback for when the translation service or its locale changes. Also applies the translation to all contained sections.
    • persist

      public void persist()
      Persists the values for all elements contained in this form's groups.
    • reset

      public void reset()
      Resets the values for all elements contained in this form's groups.
    • setChangedProperty

      protected void setChangedProperty()
      Sets this form's changed property based on its contained groups' changed properties.
    • setValidProperty

      protected void setValidProperty()
      Sets this form's valid property based on its contained groups' changed properties.
    • setPersistableProperty

      protected void setPersistableProperty()
      Sets this form's persistable property based on its contained groups' persistable properties.
    • getGroups

      public List<Group> getGroups()
    • getElements

      public List<Element> getElements()
    • getFields

      public List<Field> getFields()
    • hasChanged

      public boolean hasChanged()
    • changedProperty

      public javafx.beans.property.BooleanProperty changedProperty()
    • isValid

      public boolean isValid()
      Gets the value of the property valid.
      Property description:
      The form acts as a proxy for its contained sections' changed and valid properties.
    • validProperty

      public javafx.beans.property.BooleanProperty validProperty()
      The form acts as a proxy for its contained sections' changed and valid properties.
      See Also:
      isValid()
    • isPersistable

      public boolean isPersistable()
      Gets the value of the property persistable.
      Property description:
    • persistableProperty

      public javafx.beans.property.BooleanProperty persistableProperty()
      See Also:
      isPersistable()
    • getTitle

      public String getTitle()
      Gets the value of the property title.
      Property description:
      The title acts as a description for the form. This property is translatable if a TranslationService is set.
    • titleProperty

      public javafx.beans.property.StringProperty titleProperty()
      The title acts as a description for the form. This property is translatable if a TranslationService is set.
      See Also:
      getTitle()
    • isI18N

      public boolean isI18N()
    • addEventHandler

      public Form addEventHandler​(javafx.event.EventType<FormEvent> eventType, javafx.event.EventHandler<? super FormEvent> eventHandler)
      Registers an event handler to this form. The handler is called when the form receives an Event of the specified type during the bubbling phase of event delivery.
      Parameters:
      eventType - the type of the events to receive by the handler
      eventHandler - the handler to register
      Throws:
      NullPointerException - if either event type or handler are null.
    • removeEventHandler

      public Form removeEventHandler​(javafx.event.EventType<FormEvent> eventType, javafx.event.EventHandler<? super FormEvent> eventHandler)
      Unregisters a previously registered event handler from this form. One handler might have been registered for different event types, so the caller needs to specify the particular event type from which to unregister the handler.
      Parameters:
      eventType - the event type from which to unregister
      eventHandler - the handler to unregister
      Throws:
      NullPointerException - if either event type or handler are null.
    • fireEvent

      protected void fireEvent​(FormEvent event)