Top Description Fields Constructors Methods
com.dlsc.formsfx.model.structure

public Class Form

extends Object
Class Inheritance
Imports
com.dlsc.formsfx.model.event.FormEvent, com.dlsc.formsfx.model.util.BindingMode, .TranslationService, javafx.beans.property.BooleanProperty, .ObjectProperty, .SimpleBooleanProperty, .SimpleObjectProperty, .SimpleStringProperty, .StringProperty, javafx.event.EventHandler, .EventType, java.util.ArrayList, .Collections, .List, .Map, java.util.concurrent.ConcurrentHashMap, .CopyOnWriteArrayList, java.util.stream.Collectors

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.
Authors
Sacha Schmid, Rinesch Murugathas

Field Summary

Modifier and TypeField and Description
protected final BooleanProperty
private final Map<EventType<FormEvent>, List<EventHandler<? super FormEvent>>>
protected final List<Group>
protected final Runnable
protected final BooleanProperty
protected final StringProperty
title

The title acts as a description for the form.

protected final StringProperty
protected final ObjectProperty<TranslationService>
translationService

A form can optionally have a translation service.

protected final BooleanProperty
valid

The form acts as a proxy for its contained sections' changed and valid properties.

Constructor Summary

AccessConstructor and Description
private
Form(Group...
A varargs list of groups that are contained in this form.
groups
)

Internal constructor for the Form class.

Method Summary

Modifier and TypeMethod and Description
public Form
addEventHandler(EventType<FormEvent>
the type of the events to receive by the handler
eventType
,
EventHandler<? super FormEvent>
the handler to register
eventHandler
)

Registers an event handler to this form.

public Form

Returns:

Returns the current form to allow for chaining.
binding
(BindingMode
The new mode for handling external bindings.
newValue
)

Changes the way field values are bound to external properties.

public BooleanProperty
protected void
public List<Element<E extends Element<E>>>
public List<Field<F extends Field<F>>>
public List<Group>
public String
public boolean
public Form

Returns:

Returns the current form to allow for chaining.
i18n
(TranslationService
The new value for the translation service property.
newValue
)

Sets the translation service property of the current form.

public boolean
public boolean
public boolean
public static Form

Returns:

Returns a new Form.
of
(Group...
The sections to be included in the form.
sections
)

Creates a new form containing the given sections.

public void
persist()

Persists the values for all elements contained in this form's groups.

public BooleanProperty
public Form
removeEventHandler(EventType<FormEvent>
the event type from which to unregister
eventType
,
EventHandler<? super FormEvent>
the handler to unregister
eventHandler
)

Unregisters a previously registered event handler from this form.

public 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.

public Form

Returns:

Returns the current form to allow for chaining.
title
(String
The new value for the title property. This can be the title itself or a key that is then used for translation.
newValue
)

Sets the title property of the current form.

public StringProperty
protected void
translate()

This internal method is used as a callback for when the translation service or its locale changes.

public BooleanProperty
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

changedback to summary
protected final BooleanProperty changed
eventHandlersback to summary
private final Map<EventType<FormEvent>, List<EventHandler<? super FormEvent>>> eventHandlers
groupsback to summary
protected final List<Group> groups
localeChangeListenerback to summary
protected final Runnable localeChangeListener
persistableback to summary
protected final BooleanProperty persistable
titleback to summary
protected final StringProperty title

The title acts as a description for the form. This property is translatable if a TranslationService is set.

titleKeyback to summary
protected final StringProperty titleKey
translationServiceback to summary
protected final 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
validback to summary
protected final BooleanProperty valid

The form acts as a proxy for its contained sections' changed and valid properties.

Constructor Detail

Formback to summary
private Form(Group... groups)

Internal constructor for the Form class. To create new forms, see the static factory method in this class.

Parameters
groups:Group[]

A varargs list of groups that are contained in this form.

See Also
Form::of

Method Detail

addEventHandlerback to summary
public Form addEventHandler(EventType<FormEvent> eventType, 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:EventType<FormEvent>

the type of the events to receive by the handler

eventHandler:EventHandler<? super FormEvent>

the handler to register

Exceptions
NullPointerException:
if either event type or handler are null.
bindingback to summary
public Form binding(BindingMode newValue)

Changes the way field values are bound to external properties.

Parameters
newValue:BindingMode

The new mode for handling external bindings.

Returns:Form

Returns the current form to allow for chaining.

See Also
BindingMode
changedPropertyback to summary
public BooleanProperty changedProperty()
fireEventback to summary
protected void fireEvent(FormEvent event)
getElementsback to summary
public List<Element<E extends Element<E>>> getElements()
getFieldsback to summary
public List<Field<F extends Field<F>>> getFields()
getGroupsback to summary
public List<Group> getGroups()
getTitleback to summary
public String getTitle()
hasChangedback to summary
public boolean hasChanged()
i18nback to summary
public Form i18n(TranslationService newValue)

Sets the translation service property of the current form.

Parameters
newValue:TranslationService

The new value for the translation service property.

Returns:Form

Returns the current form to allow for chaining.

isI18Nback to summary
public boolean isI18N()
isPersistableback to summary
public boolean isPersistable()
isValidback to summary
public boolean isValid()
ofback to summary
public static Form of(Group... sections)

Creates a new form containing the given sections.

Parameters
sections:Group[]

The sections to be included in the form.

Returns:Form

Returns a new Form.

persistback to summary
public void persist()

Persists the values for all elements contained in this form's groups.

See Also
Field::reset
persistablePropertyback to summary
public BooleanProperty persistableProperty()
removeEventHandlerback to summary
public Form removeEventHandler(EventType<FormEvent> eventType, 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:EventType<FormEvent>

the event type from which to unregister

eventHandler:EventHandler<? super FormEvent>

the handler to unregister

Exceptions
NullPointerException:
if either event type or handler are null.
resetback to summary
public void reset()

Resets the values for all elements contained in this form's groups.

See Also
Field::reset
setChangedPropertyback to summary
protected void setChangedProperty()

Sets this form's changed property based on its contained groups' changed properties.

setPersistablePropertyback to summary
protected void setPersistableProperty()

Sets this form's persistable property based on its contained groups' persistable properties.

setValidPropertyback to summary
protected void setValidProperty()

Sets this form's valid property based on its contained groups' changed properties.

titleback to summary
public Form title(String newValue)

Sets the title property of the current form.

Parameters
newValue:String

The new value for the title property. This can be the title itself or a key that is then used for translation.

Returns:Form

Returns the current form to allow for chaining.

See Also
TranslationService
titlePropertyback to summary
public StringProperty titleProperty()
translateback to summary
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.

See Also
Group::translate
validPropertyback to summary
public BooleanProperty validProperty()