Module com.dlsc.formsfx
Package com.dlsc.formsfx.model.structure
Class DataField<P extends javafx.beans.property.Property,V,F extends Field<F>>
java.lang.Object
com.dlsc.formsfx.model.structure.Element<F>
com.dlsc.formsfx.model.structure.Field<F>
com.dlsc.formsfx.model.structure.DataField<P,V,F>
- All Implemented Interfaces:
FormElement
- Direct Known Subclasses:
BooleanField,DateField,DoubleField,IntegerField,PasswordField,StringField
public abstract class DataField<P extends javafx.beans.property.Property,V,F extends Field<F>> extends Field<F>
DataField holds a single value. This value can be represented and
manipulated as a String. It is stored as a concrete type.- Author:
- Sacha Schmid, Rinesch Murugathas
-
Property Summary
Properties Type Property Description javafx.beans.property.StringPropertyuserInputPvalueEvery field tracks its value in multiple ways.Properties inherited from class com.dlsc.formsfx.model.structure.Field
changed, editable, errorMessages, label, placeholder, required, tooltip, valid -
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classDataField.AbstractStringConverter<V> -
Field Summary
Fields Modifier and Type Field Description protected javafx.beans.property.StringPropertyformatErrorprotected javafx.beans.property.StringPropertyformatErrorKeyThe format error is displayed when the value transformation fails.protected PpersistentValueprotected javafx.util.StringConverter<V>stringConverterprotected javafx.beans.property.StringPropertyuserInputprotected List<Validator<V>>validatorsEvery field contains a list of validators.protected PvalueEvery field tracks its value in multiple ways.Fields inherited from class com.dlsc.formsfx.model.structure.Field
bindingModeListener, changed, editable, errorMessageKeys, errorMessages, eventHandlers, id, label, labelKey, placeholder, placeholderKey, renderer, rendererSupplier, required, requiredError, requiredErrorKey, span, styleClass, tooltip, tooltipKey, translationService, valid -
Constructor Summary
-
Method Summary
Modifier and Type Method Description Fbind(P binding)Binds the given property with the field.Fformat(ValueTransformer<V> newValue)Deprecated.Use format(StringConverter) insteadFformat(ValueTransformer<V> newValue, String errorMessage)Deprecated.Use format(StringConverter, errorMessage) insteadFformat(String errorMessage)Adds an error message to handle formatting errors with the default value transformers.Fformat(javafx.util.StringConverter<V> newValue)Sets the string converter for the current field.Fformat(javafx.util.StringConverter<V> newValue, String errorMessage)Applies a new string converter that converts the entered string input to a concrete value.StringgetUserInput()Gets the value of the property userInput.VgetValue()Gets the value of the property value.voidpersist()Stores the field's current value in its persistent value.voidreset()Sets the field's current value to its persistent value, thus resetting any changes made by the user.voidsetBindingMode(BindingMode newValue)Activates or deactivates thebindingModeListenerbased on the givenBindingMode.voidtranslate(TranslationService service)This internal method is called by the containing section when a new translation has been added to the form.Funbind(P binding)Unbinds the given property with the field.javafx.beans.property.StringPropertyuserInputProperty()booleanvalidate()Validates a user input based on the field's value transformer and its validation rules.Fvalidate(Validator<V>... newValue)Sets the list of validators for the current field.protected booleanvalidateRequired(String newValue)Validates that the new field input matches the required condition.PvalueProperty()Every field tracks its value in multiple ways.Methods inherited from class com.dlsc.formsfx.model.structure.Field
addEventHandler, changedProperty, editable, editableProperty, errorMessagesProperty, fireEvent, getErrorMessages, getLabel, getLabelDescription, getPlaceholder, getRenderer, getTooltip, getValueDescription, hasChanged, isEditable, isI18N, isRequired, isValid, label, labelDescription, labelDescription, labelProperty, ofBooleanType, ofBooleanType, ofDate, ofDate, ofDoubleType, ofDoubleType, ofIntegerType, ofIntegerType, ofMultiSelectionType, ofMultiSelectionType, ofMultiSelectionType, ofPasswordType, ofPasswordType, ofSingleSelectionType, ofSingleSelectionType, ofSingleSelectionType, ofStringType, ofStringType, placeholder, placeholderProperty, removeEventHandler, render, render, required, required, requiredProperty, tooltip, tooltipProperty, updateElement, validProperty, valueDescription, valueDescriptionMethods inherited from class com.dlsc.formsfx.model.structure.Element
getID, getSpan, getStyleClass, id, idProperty, span, span, spanProperty, styleClass, styleClassProperty
-
Property Details
-
userInput
public javafx.beans.property.StringProperty userInputProperty- See Also:
getUserInput()
-
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.- See Also:
getValue()
-
-
Field Details
-
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. -
persistentValue
-
userInput
protected final javafx.beans.property.StringProperty userInput -
validators
Every field contains a list of validators. The validators are limited to the ones that correspond to the field's type. -
stringConverter
-
formatErrorKey
protected final javafx.beans.property.StringProperty formatErrorKeyThe format error is displayed when the value transformation fails. This property is translatable if aTranslationServiceis set on the containing form. -
formatError
protected final javafx.beans.property.StringProperty formatError
-
-
Constructor Details
-
DataField
Internal constructor for theDataFieldclass. To create new elements, see the static factory methods inField.- Parameters:
valueProperty- The property that is used to store the current valid value of the field.persistentValueProperty- The property that is used to store the latest persisted value of the field.
-
-
Method Details
-
format
Sets the string converter for the current field.- Parameters:
newValue- The string converter that transforms the user input string to the field's underlying value and back.- Returns:
- Returns the current field to allow for chaining.
-
format
Applies a new string converter that converts the entered string input to a concrete value.- Parameters:
newValue- The string converter that transforms the user input string to the field's underlying value and back.errorMessage- The error message to display if the transformation was unsuccessful.- Returns:
- Returns the current field to allow for chaining.
-
format
Deprecated.Use format(StringConverter) insteadSets the value transformer for the current field.- Parameters:
newValue- The value transformer that parses the user input string to the field's underlying value.- Returns:
- Returns the current field to allow for chaining.
-
format
Deprecated.Use format(StringConverter, errorMessage) insteadApplies a new value transformer that converts the entered string input to a concrete value.- Parameters:
newValue- The new value transformer. Takes a string as an input and returns the concrete type.errorMessage- The error message to display if the transformation was unsuccessful.- Returns:
- Returns the current field to allow for chaining.
-
format
Adds an error message to handle formatting errors with the default value transformers.- Parameters:
errorMessage- The error message to display if the transformation was unsuccessful.- Returns:
- Returns the current field to allow for chaining.
-
validate
Sets the list of validators for the current field. This overrides all validators that have previously been added.- Parameters:
newValue- 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:
- Returns the current field to allow for chaining.
-
bind
Binds the given property with the field.- Parameters:
binding- The property to be bound with.- Returns:
- Returns the current field to allow for chaining.
-
unbind
Unbinds the given property with the field.- Parameters:
binding- The property to be unbound with.- Returns:
- Returns the current field to allow for chaining.
-
setBindingMode
Activates or deactivates thebindingModeListenerbased on the givenBindingMode.- Specified by:
setBindingModein classField<F extends Field<F>>- Parameters:
newValue- The new binding mode for the current field.
-
persist
public void persist()Stores the field's current value in its persistent value. This stores the user's changes in the model. -
reset
public void reset()Sets the field's current value to its persistent value, thus resetting any changes made by the user. -
validateRequired
Validates that the new field input matches the required condition.- Parameters:
newValue- The new value to check for the required state.- Returns:
- Returns whether the input matches the required condition.
-
validate
public boolean validate()Validates a user input based on the field's value transformer and its validation rules. Also considers therequiredflag. This method directly updates thevalidproperty. -
translate
This internal method is called by the containing section when a new translation has been added to the form. -
getUserInput
Gets the value of the property userInput.- Property description:
-
userInputProperty
public javafx.beans.property.StringProperty userInputProperty()- See Also:
getUserInput()
-
getValue
Gets the value of the property value.- Property description:
- 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.
-
valueProperty
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.- See Also:
getValue()
-