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

public abstract Class DataField<P extends Property<T>, V, F extends Field<F>>

extends Field<F extends Field<F>>
Class Inheritance
Known Direct Subclasses
com.dlsc.formsfx.model.structure.DateField, com.dlsc.formsfx.model.structure.DoubleField, com.dlsc.formsfx.model.structure.IntegerField, com.dlsc.formsfx.model.structure.PasswordField, com.dlsc.formsfx.model.structure.StringField, com.dlsc.formsfx.model.structure.BooleanField
Imports
com.dlsc.formsfx.model.event.FieldEvent, com.dlsc.formsfx.model.util.BindingMode, .TranslationService, .ValueTransformer, com.dlsc.formsfx.model.validators.ValidationResult, .Validator, javafx.beans.InvalidationListener, javafx.beans.binding.Bindings, javafx.beans.property.Property, .SimpleStringProperty, .StringProperty, javafx.util.StringConverter, java.util.ArrayList, .Collections, .List, java.util.stream.Collectors

DataField holds a single value. This value can be represented and manipulated as a String. It is stored as a concrete type.
Authors
Sacha Schmid, Rinesch Murugathas

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected abstract static class
private static class

Field Summary

Modifier and TypeField and Description
private final InvalidationListener
externalBindingListener

This listener updates the field when the external binding changes.

protected final StringProperty
protected final StringProperty
formatErrorKey

The format error is displayed when the value transformation fails.

protected final P
protected StringConverter<V>
protected final StringProperty
protected final List<Validator<V>>
validators

Every field contains a list of validators.

protected final P
value

Every field tracks its value in multiple ways.

pack-priv ValueTransformer<V>
valueTransformer

Deprecated Use DataField#stringConverter instead.
The value transformer is responsible for transforming the user input string to the specific type of the field's value.
Inherited from com.dlsc.formsfx.model.structure.Field:
bindingModeListenerchangededitableerrorMessageKeyserrorMessageseventHandlersidlabellabelKeyplaceholderplaceholderKeyrendererrendererSupplierrequiredrequiredErrorrequiredErrorKeyspanstyleClasstooltiptooltipKeytranslationServicevalid

Constructor Summary

AccessConstructor and Description
protected
DataField(P
The property that is used to store the current valid value of the field.
valueProperty
,
P
The property that is used to store the latest persisted value of the field.
persistentValueProperty
)

Internal constructor for the DataField class.

Method Summary

Modifier and TypeMethod and Description
public F

Returns:

Returns the current field to allow for chaining.
bind
(P
The property to be bound with.
binding
)

Binds the given property with the field.

public F

Returns:

Returns the current field to allow for chaining.
format
(StringConverter<V>
The string converter that transforms the user input string to the field's underlying value and back.
newValue
)

Sets the string converter for the current field.

public F

Returns:

Returns the current field to allow for chaining.
format
(StringConverter<V>
The string converter that transforms the user input string to the field's underlying value and back.
newValue
,
String
The error message to display if the transformation was unsuccessful.
errorMessage
)

Applies a new string converter that converts the entered string input to a concrete value.

public F

Returns:

Returns the current field to allow for chaining.
format
(ValueTransformer<V>
The value transformer that parses the user input string to the field's underlying value.
newValue
)
Deprecated Use format(StringConverter) instead

Sets the value transformer for the current field.

public F

Returns:

Returns the current field to allow for chaining.
format
(ValueTransformer<V>
The new value transformer. Takes a string as an input and returns the concrete type.
newValue
,
String
The error message to display if the transformation was unsuccessful.
errorMessage
)
Deprecated Use format(StringConverter, errorMessage) instead

Applies a new value transformer that converts the entered string input to a concrete value.

public F

Returns:

Returns the current field to allow for chaining.
format
(String
The error message to display if the transformation was unsuccessful.
errorMessage
)

Adds an error message to handle formatting errors with the default value transformers.

public String
public V
public void
persist()

Implements com.dlsc.formsfx.model.structure.FormElement.persist.

Stores the field's current value in its persistent value.

public void
reset()

Implements com.dlsc.formsfx.model.structure.FormElement.reset.

Sets the field's current value to its persistent value, thus resetting any changes made by the user.

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

Implements abstract com.dlsc.formsfx.model.structure.Field.setBindingMode.

Activates or deactivates the bindingModeListener based on the given BindingMode.

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

Overrides com.dlsc.formsfx.model.structure.Field.translate.

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

public F

Returns:

Returns the current field to allow for chaining.
unbind
(P
The property to be unbound with.
binding
)

Unbinds the given property with the field.

public StringProperty
public final F

Returns:

Returns the current field to allow for chaining.
validate
(Validator<V>...
The validators that are to be used for validating this field. Limited to validators that are able to handle the field's underlying type.
newValue
)

Sets the list of validators for the current field.

public boolean

Returns:

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

Implements abstract com.dlsc.formsfx.model.structure.Field.validate.

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

protected boolean

Returns:

Returns whether the input matches the required condition.
validateRequired
(String
The new value to check for the required state.
newValue
)

Validates that the new field input matches the required condition.

public P
Inherited from com.dlsc.formsfx.model.structure.Field:
addEventHandlerchangedPropertyeditableeditablePropertyerrorMessagesPropertyfireEventgetErrorMessagesgetLabelgetLabelDescriptiongetPlaceholdergetRenderergetTooltipgetValueDescriptionhasChangedisEditableisI18NisRequiredisValidlabellabelDescriptionlabelDescriptionlabelPropertyofBooleanTypeofBooleanTypeofDateofDateofDoubleTypeofDoubleTypeofIntegerTypeofIntegerTypeofMultiSelectionTypeofMultiSelectionTypeofMultiSelectionTypeofPasswordTypeofPasswordTypeofSingleSelectionTypeofSingleSelectionTypeofSingleSelectionTypeofStringTypeofStringTypeplaceholderplaceholderPropertyremoveEventHandlerrenderrenderrequiredrequiredrequiredPropertytooltiptooltipPropertyupdateElementupdateElementvalidPropertyvalueDescriptionvalueDescription

Field Detail

externalBindingListenerback to summary
private final InvalidationListener externalBindingListener

This listener updates the field when the external binding changes.

formatErrorback to summary
protected final StringProperty formatError
formatErrorKeyback to summary
protected final StringProperty formatErrorKey

The format error is displayed when the value transformation fails. This property is translatable if a TranslationService is set on the containing form.

persistentValueback to summary
protected final P persistentValue
stringConverterback to summary
protected StringConverter<V> stringConverter
userInputback to summary
protected final StringProperty userInput
validatorsback to summary
protected final List<Validator<V>> validators

Every field contains a list of validators. The validators are limited to the ones that correspond to the field's type.

valueback to summary
protected final P value

Every field tracks its value in multiple ways. - The user input is bound to a specific control's input value and is a 1-to-1 representation of what the user enters. - The value is the last valid value entered by the user. This means that the value passes the type transformation of the concrete field and all user-defined validations. - The persistent value is the value that was last saved on the field. It is the responsibility of the form creator to persist the field values at the correct time.

valueTransformerback to summary
pack-priv ValueTransformer<V> valueTransformer

Deprecated

Use DataField#stringConverter instead.

The value transformer is responsible for transforming the user input string to the specific type of the field's value.

Annotations
@Deprecated

Constructor Detail

DataFieldback to summary
protected DataField(P valueProperty, P persistentValueProperty)

Internal constructor for the DataField class. To create new elements, see the static factory methods in Field.

Parameters
valueProperty:P

The property that is used to store the current valid value of the field.

persistentValueProperty:P

The property that is used to store the latest persisted value of the field.

See Also
Field::ofStringType, Field::ofIntegerType, Field::ofDoubleType, Field::ofBooleanType

Method Detail

bindback to summary
public F bind(P binding)

Binds the given property with the field.

Parameters
binding:P

The property to be bound with.

Returns:F

Returns the current field to allow for chaining.

formatback to summary
public F format(StringConverter<V> newValue)

Sets the string converter for the current field.

Parameters
newValue:StringConverter<V>

The string converter that transforms the user input string to the field's underlying value and back.

Returns:F

Returns the current field to allow for chaining.

formatback to summary
public F format(StringConverter<V> newValue, String errorMessage)

Applies a new string converter that converts the entered string input to a concrete value.

Parameters
newValue:StringConverter<V>

The string converter that transforms the user input string to the field's underlying value and back.

errorMessage:String

The error message to display if the transformation was unsuccessful.

Returns:F

Returns the current field to allow for chaining.

formatback to summary
public F format(ValueTransformer<V> newValue)

Deprecated

Use format(StringConverter) instead

Sets the value transformer for the current field.

Parameters
newValue:ValueTransformer<V>

The value transformer that parses the user input string to the field's underlying value.

Returns:F

Returns the current field to allow for chaining.

Annotations
@Deprecated
formatback to summary
public F format(ValueTransformer<V> newValue, String errorMessage)

Deprecated

Use format(StringConverter, errorMessage) instead

Applies a new value transformer that converts the entered string input to a concrete value.

Parameters
newValue:ValueTransformer<V>

The new value transformer. Takes a string as an input and returns the concrete type.

errorMessage:String

The error message to display if the transformation was unsuccessful.

Returns:F

Returns the current field to allow for chaining.

Annotations
@Deprecated
formatback to summary
public F format(String errorMessage)

Adds an error message to handle formatting errors with the default value transformers.

Parameters
errorMessage:String

The error message to display if the transformation was unsuccessful.

Returns:F

Returns the current field to allow for chaining.

getUserInputback to summary
public String getUserInput()
getValueback to summary
public V getValue()
persistback to summary
public void persist()

Implements com.dlsc.formsfx.model.structure.FormElement.persist.

Stores the field's current value in its persistent value. This stores the user's changes in the model.

resetback to summary
public void reset()

Implements com.dlsc.formsfx.model.structure.FormElement.reset.

Sets the field's current value to its persistent value, thus resetting any changes made by the user.

setBindingModeback to summary
public void setBindingMode(BindingMode newValue)

Implements abstract com.dlsc.formsfx.model.structure.Field.setBindingMode.

Doc from com.dlsc.formsfx.model.structure.Field.setBindingMode.

Activates or deactivates the bindingModeListener based on the given BindingMode.

Parameters
newValue:BindingMode

The new binding mode for the current field.

translateback to summary
public void translate(TranslationService service)

Overrides com.dlsc.formsfx.model.structure.Field.translate.

Doc from com.dlsc.formsfx.model.structure.Field.translate.

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

Parameters
service:TranslationService

The new service to use for translating translatable values.

unbindback to summary
public F unbind(P binding)

Unbinds the given property with the field.

Parameters
binding:P

The property to be unbound with.

Returns:F

Returns the current field to allow for chaining.

userInputPropertyback to summary
public StringProperty userInputProperty()
validateback to summary
public final F validate(Validator<V>... newValue)

Sets the list of validators for the current field. This overrides all validators that have previously been added.

Parameters
newValue:Validator<V>[]

The validators that are to be used for validating this field. Limited to validators that are able to handle the field's underlying type.

Returns:F

Returns the current field to allow for chaining.

Annotations
@SafeVarargs
validateback to summary
public boolean validate()

Implements abstract com.dlsc.formsfx.model.structure.Field.validate.

Validates a user input based on the field's value transformer and its validation rules. Also considers the required flag. This method directly updates the valid property.

Returns:boolean

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

validateRequiredback to summary
protected boolean validateRequired(String newValue)

Validates that the new field input matches the required condition.

Parameters
newValue:String

The new value to check for the required state.

Returns:boolean

Returns whether the input matches the required condition.

valuePropertyback to summary
public P valueProperty()
com.dlsc.formsfx.model.structure back to summary

protected abstract Class DataField.AbstractStringConverter<V>

extends StringConverter<V>
Class Inheritance
Known Direct Subclasses
com.dlsc.formsfx.model.structure.DataField.StringConverterAdapter

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public String
toString(V
the object of type T to convert
object
)

Implements abstract javafx.util.StringConverter.toString.

Converts the object provided into its string form.

Inherited from javafx.util.StringConverter:
fromString

Constructor Detail

AbstractStringConverterback to summary
protected AbstractStringConverter()

Method Detail

toStringback to summary
public String toString(V object)

Implements abstract javafx.util.StringConverter.toString.

Doc from javafx.util.StringConverter.toString.

Converts the object provided into its string form. Format of the returned string is defined by the specific converter.

Parameters
object:V

the object of type T to convert

Returns:String

a string representation of the object passed in

Annotations
@Override
com.dlsc.formsfx.model.structure back to summary

private Class DataField.StringConverterAdapter<V>

extends DataField.AbstractStringConverter<V>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ValueTransformer<V>
valueTransformer

References Deprecated ValueTransformer is deprecated or references (maybe indirectly) at least one deprecated element.

Constructor Summary

AccessConstructor and Description
public
StringConverterAdapter(ValueTransformer<V> valueTransformer)
References Deprecated ValueTransformer is deprecated or references (maybe indirectly) at least one deprecated element.

Method Summary

Modifier and TypeMethod and Description
public V
fromString(String
the String to convert
string
)

Implements abstract javafx.util.StringConverter.fromString.

Converts the string provided into an object defined by the specific converter.

Inherited from com.dlsc.formsfx.model.structure.DataField.AbstractStringConverter:
toString

Field Detail

valueTransformerback to summary
private final ValueTransformer<V> valueTransformer

References Deprecated

ValueTransformer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Constructor Detail

StringConverterAdapterback to summary
public StringConverterAdapter(ValueTransformer<V> valueTransformer)

References Deprecated

ValueTransformer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Method Detail

fromStringback to summary
public V fromString(String string)

Implements abstract javafx.util.StringConverter.fromString.

Doc from javafx.util.StringConverter.fromString.

Converts the string provided into an object defined by the specific converter. Format of the string and type of the resulting object is defined by the specific converter.

Parameters
string:String

the String to convert

Returns:V

an object representation of the string passed in.

Annotations
@Override