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.BooleanPropertychangedjavafx.beans.property.BooleanPropertypersistablejavafx.beans.property.StringPropertytitleThe title acts as a description for the form.javafx.beans.property.BooleanPropertyvalidThe form acts as a proxy for its contained sections'changedandvalidproperties. -
Field Summary
Fields Modifier and Type Field Description protected javafx.beans.property.BooleanPropertychangedprotected List<Group>groupsprotected RunnablelocaleChangeListenerprotected javafx.beans.property.BooleanPropertypersistableprotected javafx.beans.property.StringPropertytitleThe title acts as a description for the form.protected javafx.beans.property.StringPropertytitleKeyprotected javafx.beans.property.ObjectProperty<TranslationService>translationServiceA form can optionally have a translation service.protected javafx.beans.property.BooleanPropertyvalidThe form acts as a proxy for its contained sections'changedandvalidproperties. -
Method Summary
Modifier and Type Method Description FormaddEventHandler(javafx.event.EventType<FormEvent> eventType, javafx.event.EventHandler<? super FormEvent> eventHandler)Registers an event handler to this form.Formbinding(BindingMode newValue)Changes the way field values are bound to external properties.javafx.beans.property.BooleanPropertychangedProperty()protected voidfireEvent(FormEvent event)List<Element>getElements()List<Field>getFields()List<Group>getGroups()StringgetTitle()Gets the value of the property title.booleanhasChanged()Formi18n(TranslationService newValue)Sets the translation service property of the current form.booleanisI18N()booleanisPersistable()Gets the value of the property persistable.booleanisValid()Gets the value of the property valid.static Formof(Group... sections)Creates a new form containing the given sections.voidpersist()Persists the values for all elements contained in this form's groups.javafx.beans.property.BooleanPropertypersistableProperty()FormremoveEventHandler(javafx.event.EventType<FormEvent> eventType, javafx.event.EventHandler<? super FormEvent> eventHandler)Unregisters a previously registered event handler from this form.voidreset()Resets the values for all elements contained in this form's groups.protected voidsetChangedProperty()Sets this form'schangedproperty based on its contained groups' changed properties.protected voidsetPersistableProperty()Sets this form'spersistableproperty based on its contained groups' persistable properties.protected voidsetValidProperty()Sets this form'svalidproperty based on its contained groups' changed properties.Formtitle(String newValue)Sets the title property of the current form.javafx.beans.property.StringPropertytitleProperty()The title acts as a description for the form.protected voidtranslate()This internal method is used as a callback for when the translation service or its locale changes.javafx.beans.property.BooleanPropertyvalidProperty()The form acts as a proxy for its contained sections'changedandvalidproperties.
-
Property Details
-
changed
public javafx.beans.property.BooleanProperty changedProperty -
valid
public javafx.beans.property.BooleanProperty validPropertyThe form acts as a proxy for its contained sections'changedandvalidproperties.- See Also:
isValid()
-
persistable
public javafx.beans.property.BooleanProperty persistableProperty- See Also:
isPersistable()
-
title
public javafx.beans.property.StringProperty titlePropertyThe title acts as a description for the form. This property is translatable if aTranslationServiceis set.- See Also:
getTitle()
-
-
Field Details
-
groups
-
title
protected final javafx.beans.property.StringProperty titleThe title acts as a description for the form. This property is translatable if aTranslationServiceis set. -
titleKey
protected final javafx.beans.property.StringProperty titleKey -
valid
protected final javafx.beans.property.BooleanProperty validThe form acts as a proxy for its contained sections'changedandvalidproperties. -
changed
protected final javafx.beans.property.BooleanProperty changed -
persistable
protected final javafx.beans.property.BooleanProperty persistable -
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
-
-
Method Details
-
of
Creates a new form containing the given sections.- Parameters:
sections- The sections to be included in the form.- Returns:
- Returns a new
Form.
-
title
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
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
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'schangedproperty based on its contained groups' changed properties. -
setValidProperty
protected void setValidProperty()Sets this form'svalidproperty based on its contained groups' changed properties. -
setPersistableProperty
protected void setPersistableProperty()Sets this form'spersistableproperty based on its contained groups' persistable properties. -
getGroups
-
getElements
-
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'
changedandvalidproperties.
-
validProperty
public javafx.beans.property.BooleanProperty validProperty()The form acts as a proxy for its contained sections'changedandvalidproperties.- 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
Gets the value of the property title.- Property description:
- The title acts as a description for the form.
This property is translatable if a
TranslationServiceis set.
-
titleProperty
public javafx.beans.property.StringProperty titleProperty()The title acts as a description for the form. This property is translatable if aTranslationServiceis 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 anEventof the specified type during the bubbling phase of event delivery.- Parameters:
eventType- the type of the events to receive by the handlereventHandler- the handler to register- Throws:
NullPointerException- if either event type or handler arenull.
-
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 unregistereventHandler- the handler to unregister- Throws:
NullPointerException- if either event type or handler arenull.
-
fireEvent
-