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

public abstract Class Field<F extends Field<F>>

extends Element<F extends Field<F>>
implements FormElement
Class Inheritance
All Implemented Interfaces
com.dlsc.formsfx.model.structure.FormElement
Known Direct Subclasses
com.dlsc.formsfx.model.structure.SelectionField, com.dlsc.formsfx.model.structure.DataField
Imports
com.dlsc.formsfx.model.event.FieldEvent, com.dlsc.formsfx.model.util.BindingMode, .TranslationService, com.dlsc.formsfx.view.controls.SimpleControl, javafx.beans.InvalidationListener, javafx.beans.property.*, javafx.collections.FXCollections, .ObservableList, java.time.LocalDate, java.util.ArrayList, .List, .ArrayList, .List, .Map, .UUID, javafx.event.EventHandler, .EventType, javafx.scene.Node, javafx.scene.control.Label, .Labeled, java.util.concurrent.ConcurrentHashMap, .CopyOnWriteArrayList, java.util.function.Supplier, java.util.stream.Collectors

This class provides the base implementation for a FormsFX field. It is not meant to be used directly, but instead acts as a base for concrete implementations. A field is the smallest unit of the form. It contains only the value and relevant information.
Authors
Sacha Schmid, Rinesch Murugathas

Field Summary

Modifier and TypeField and Description
protected final InvalidationListener
bindingModeListener

With the continuous binding mode, values are always directly persisted upon any changes.

protected final BooleanProperty
protected final BooleanProperty
protected final ListProperty<String>
protected final ListProperty<String>
errorMessages

The results of the field's validation is stored in this property.

protected final Map<EventType<FieldEvent>, List<EventHandler<? super FieldEvent>>>
protected final StringProperty
id

Hides com.dlsc.formsfx.model.structure.Element.id.

Fields can be styled using CSS through ID or class hooks.
protected final StringProperty
label

The label acts as a description for the field.

private static final String
private Node
labelDescription

Additional descriptions for the field's label and value are stored in these properties.

private final StringProperty
protected final StringProperty
protected final StringProperty
placeholder

The placeholder is only visible in an empty field.

protected final StringProperty
protected SimpleControl<F>
protected Supplier<SimpleControl<F>>
protected final BooleanProperty
protected final StringProperty
protected final StringProperty
requiredErrorKey

Every field can be marked as required and editable.

protected final IntegerProperty
protected final ListProperty<String>
protected final StringProperty
tooltip

The tooltip is an extension of the label.

protected final StringProperty
protected TranslationService
translationService

The translation service is passed down from the containing section.

protected final BooleanProperty
valid

The field's current state is represented by the value properties, as well as by the valid and changed flags.

private static final String
private Node
private final StringProperty

Constructor Summary

AccessConstructor and Description
protected
Field()

Internal constructor for the Field class.

Method Summary

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

Registers an event handler to this field.

private Label
asLabel(String text, String styleClass)

public BooleanProperty
public F

Returns:

Returns the current field to allow for chaining.
editable
(boolean
The new value for the editable property.
newValue
)

Sets the editable property of the current field.

public BooleanProperty
public ListProperty<String>
protected void
public List<String>
public String
public Node
public String
public SimpleControl<F>
public String
public Node
public boolean
public boolean
public boolean
public boolean
public boolean
public F

Returns:

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

Sets the label property of the current field.

public F

Returns:

Returns the current field to allow for chaining.
labelDescription
(Node
The new value for the label description property.
newValue
)

Sets the label description property of the current field.

public F

Returns:

Returns the current field to allow for chaining.
labelDescription
(String
The new value for the label description property, wrapped with a Text.
newValue
)

Sets the label description property of the current field.

public StringProperty
public static BooleanField

Returns:

Returns a new BooleanField.
ofBooleanType
(boolean
The initial value and persistent value of the field.
defaultValue
)

Creates a new BooleanField with the given default value.

public static BooleanField

Returns:

Returns a new BooleanField.
ofBooleanType
(BooleanProperty
The property from the model to be bound with.
binding
)

Creates a new BooleanField with the given property.

public static DateField

Returns:

Returns a new DateField.
ofDate
(LocalDate
The initial value and persistent value of the field.
defaultValue
)

Creates a new DateField with given default value

public static DateField

Returns:

Returns a new DateField.
ofDate
(ObjectProperty<LocalDate>
The property from the model to be bound with.
binding
)

Creates a new DateField with given property

public static DoubleField

Returns:

Returns a new DoubleField.
ofDoubleType
(double
The initial value and persistent value of the field.
defaultValue
)

Creates a new DoubleField with the given default value.

public static DoubleField

Returns:

Returns a new DoubleField.
ofDoubleType
(DoubleProperty
The property from the model to be bound with.
binding
)

Creates a new DoubleField with the given property.

public static IntegerField

Returns:

Returns a new IntegerField.
ofIntegerType
(int
The initial value and persistent value of the field.
defaultValue
)

Creates a new IntegerField with the given default value.

public static IntegerField

Returns:

Returns a new IntegerField.
ofIntegerType
(IntegerProperty
The property from the model to be bound with.
binding
)

Creates a new IntegerField with the given property.

public static <T> MultiSelectionField<T>

Returns:

Returns a new MultiSelectionField.
ofMultiSelectionType
(List<T>
The list of available items on the field.
items
,
List<Integer>
The pre-defined indices of the selected items.
selection
)

Creates a new MultiSelectionField with the given items and a pre-defined selection.

public static <T> MultiSelectionField<T>

Returns:

Returns a new MultiSelectionField.
ofMultiSelectionType
(List<T>
The list of available items on the field.
items
)

Creates a new MultiSelectionField with the given items and no pre-defined selection.

public static <T> MultiSelectionField<T>

Returns:

Returns a new MultiSelectionField.
ofMultiSelectionType
(ListProperty<T>
The items property to be bound with.
itemsBinding
,
ListProperty<T>
The selection property to be bound with.
selectionBinding
)

Creates a new MultiSelectionField with the given properties for items and selection.

public static PasswordField

Returns:

Returns a new PasswordField.
ofPasswordType
(String
The initial value and persistent value of the field.
defaultValue
)

Creates a new PasswordField with the given default value.

public static PasswordField

Returns:

Returns a new PasswordField.
ofPasswordType
(StringProperty
The property from the model to be bound with.
binding
)

Creates a new PasswordField with the given property.

public static <T> SingleSelectionField<T>

Returns:

Returns a new SingleSelectionField.
ofSingleSelectionType
(List<T>
The list of available items on the field.
items
,
int
The pre-defined index of the selected item.
selection
)

Creates a new SingleSelectionField with the given items and a pre-defined selection.

public static <T> SingleSelectionField<T>

Returns:

Returns a new SingleSelectionField.
ofSingleSelectionType
(List<T>
The list of available items on the field.
items
)

Creates a new SingleSelectionField with the given items and no pre-defined selection.

public static <T> SingleSelectionField<T>

Returns:

Returns a new SingleSelectionField.
ofSingleSelectionType
(ListProperty<T>
The items property to be bound with.
itemsBinding
,
ObjectProperty<T>
The selection property to be bound with.
selectionBinding
)

Creates a new SingleSelectionField with the given properties for items and selection.

public static StringField

Returns:

Returns a new StringField.
ofStringType
(String
The initial value and persistent value of the field.
defaultValue
)

Creates a new StringField with the given default value.

public static StringField

Returns:

Returns a new StringField.
ofStringType
(StringProperty
The property from the model to be bound with.
binding
)

Creates a new StringField with the given property.

public F

Returns:

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

Sets the placeholder property of the current field.

public StringProperty
public Field<F extends Field<F>>
removeEventHandler(EventType<FieldEvent>
the event type from which to unregister
eventType
,
EventHandler<? super FieldEvent>
the handler to unregister
eventHandler
)

Unregisters a previously registered event handler from this field.

public F

Returns:

Returns the current field to allow for chaining.
render
(SimpleControl<F>
The new control to render the field.
newValue
)

Sets the control that renders this field.

public F

Returns:

Returns the current field to allow for chaining.
render
(Supplier<SimpleControl<F>>
The new control supplier to render the field.
newValue
)

Sets the control supplier that renders this field.

public F

Returns:

Returns the current field to allow for chaining.
required
(boolean
The new state of the required property.
newValue
)

Sets the required property to for the current field without providing an error message.

public F

Returns:

Returns the current field to allow for chaining.
required
(String
The error message if the field is not filled in.
errorMessage
)

Sets the required property to true for the current field.

public BooleanProperty
public abstract void
setBindingMode(BindingMode
The new binding mode for the current field.
newValue
)

Activates or deactivates the bindingModeListener based on the given BindingMode.

public F

Returns:

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

Sets the tooltip property of the current field.

public StringProperty
public void
translate(TranslationService
The new service to use for translating translatable values.
newValue
)

This internal method is called by the containing section when a new translation has been added to the form.

protected void
updateElement(StringProperty
The property that is displayed to the user.
displayProperty
,
StringProperty
The internal property that holds the translation key.
keyProperty
)

Updates a displayable field property to include translated text.

pack-priv void
updateElement(Node
The property that is displayed to the user.
node
,
StringProperty
The internal property that holds the translation key.
keyProperty
)

Updates a displayable field property to include translated text.

protected abstract boolean

Returns:

Returns whether the user input is a valid value or not.
validate
()

Validates a user input based on the field's value transformer and its validation rules.

public BooleanProperty
public F

Returns:

Returns the current field to allow for chaining.
valueDescription
(Node
The new value for the field description property.
newValue
)

Sets the value description property of the current field.

public F

Returns:

Returns the current field to allow for chaining.
valueDescription
(String
The new value for the field description property, wrapped with a Text.
newValue
)

Sets the value description property of the current field.

Inherited from com.dlsc.formsfx.model.structure.Element:
getIDgetSpangetStyleClassididPropertyspanspanspanPropertystyleClassstyleClassProperty