Interface Field<T>
- Type Parameters:
T- the type of values in the field, which might not be the same type as that of the data source if converters are used
- All Superinterfaces:
Buffered,BufferedValidatable,Property<T>,Property.Editor,Property.ReadOnlyStatusChangeListener,Property.ReadOnlyStatusChangeNotifier,Property.ValueChangeListener,Property.ValueChangeNotifier,Property.Viewer,Serializable,Validatable
- All Known Subinterfaces:
FAbstractTextField,HasFInternalValue<T>,Select
- All Known Implementing Classes:
AbstractField,CustomField,FAbstractField,FAbstractSelect,FCheckBox,FComboBox,FDateField,FListSelect,FPasswordField,FTextArea,FTextField,FTokenField,FTwinColSelect,Table
AbstractField base clas.
The Field interface inherits the Component superinterface and also
the Property interface to have a value for the field.- Author:
- Vaadin Ltd.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classAnEventobject specifying the Field whose value has been changed.Nested classes/interfaces inherited from interface com.vaadin.featurepack.data.Buffered
Buffered.SourceExceptionNested classes/interfaces inherited from interface com.vaadin.featurepack.data.Property
Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeEvent, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer -
Method Summary
Modifier and TypeMethodDescriptiondefault voidRegisters a new read-only status change listener for this Property.default voidaddValidator(Validator validator) Adds a new validator for this object.default voidRegisters a new value change listener for this Property.default voidcommit()Updates all changes since the previous commit to the data source.default voiddiscard()Discards all changes since last commit.default Objectdefault FAbstractField<T> default PropertyGets the Property serving as the data source of the viewer.default StringGets the error message that is to be displayed if a required field is empty.getType()Returns the type of the Property.default Collection<Validator> Returns a collection of all validators currently registered for the object.default booleanChecks the buffered modebooleanisEmpty()Is the field empty?default booleanChecks the validabtable object accept invalid values.The default value istrue.default booleanTests if the invalid data is committed to datasource.default booleanTests if the value stored in the object has been modified since it was last updated from the data source.default booleanTests if the Property is in read-only mode.default booleanIs this field required.default booleanisValid()Tests the current value of the object against all registered validators.default voidNotifies this listener that a Property's read-only status has changed.default voidRemoves all validators from this object, as ifremoveValidatorwas called for each registered validator.default voidRemoves a previously registered read-only status change listener.default voidremoveValidator(Validator validator) Removes a previously registered validator from the object.default voidRemoves a previously registered value change listener.default voidsetBuffered(boolean buffered) Sets the buffered mode to the specified status.default voidsetConverter(Converter<T, ?> converter) default voidsetInvalidAllowed(boolean invalidValueAllowed) Should the validabtable object accept invalid values.default voidsetInvalidCommitted(boolean isCommitted) Sets if the invalid data should be committed to datasource.default voidsetPropertyDataSource(Property newDataSource) Sets the Property that serves as the data source of the viewer.default voidsetPropertyReadOnly(boolean newStatus) Sets the Property's read-only mode to the specified status.default voidsetRequired(boolean required) Sets the field required.default voidsetRequiredError(String requiredMessage) Sets the error message to be displayed if a required field is empty.default voidNotifies this listener that the Property's value has changed.Methods inherited from interface com.vaadin.featurepack.data.Validatable
validate
-
Method Details
-
getFAbstractField
-
setConverter
-
getConverter
-
getConvertedValue
-
isRequired
default boolean isRequired()Is this field required. Required fields must filled by the user.- Returns:
trueif the field is required,otherwisefalse.
-
setRequired
default void setRequired(boolean required) Sets the field required. Required fields must filled by the user.- Parameters:
required- Is the field required.
-
setRequiredError
Sets the error message to be displayed if a required field is empty.- Parameters:
requiredMessage- Error message.
-
getRequiredError
Gets the error message that is to be displayed if a required field is empty.- Returns:
- Error message.
-
isEmpty
boolean isEmpty()Is the field empty? In general, "empty" state is same as null. As an exception, TextField also treats empty string as "empty".- Returns:
- true if the field is empty, false otherwise
-
isInvalidCommitted
default boolean isInvalidCommitted()Description copied from interface:BufferedValidatableTests if the invalid data is committed to datasource. The default isfalse.- Specified by:
isInvalidCommittedin interfaceBufferedValidatable
-
setInvalidCommitted
default void setInvalidCommitted(boolean isCommitted) Description copied from interface:BufferedValidatableSets if the invalid data should be committed to datasource. The default isfalse.- Specified by:
setInvalidCommittedin interfaceBufferedValidatable
-
commit
Description copied from interface:BufferedUpdates all changes since the previous commit to the data source. The value stored in the object will always be updated into the data source whencommitis called.- Specified by:
commitin interfaceBuffered- Throws:
Buffered.SourceException- if the operation fails because of an exception is thrown by the data source. The cause is included in the exception.Validator.InvalidValueException- if the operation fails because validation is enabled and the values do not validate
-
discard
Description copied from interface:BufferedDiscards all changes since last commit. The object updates its value from the data source.- Specified by:
discardin interfaceBuffered- Throws:
Buffered.SourceException- if the operation fails because of an exception is thrown by the data source. The cause is included in the exception.
-
setBuffered
default void setBuffered(boolean buffered) Description copied from interface:BufferedSets the buffered mode to the specified status.When in buffered mode, an internal buffer will be used to store changes until
Buffered.commit()is called. CallingBuffered.discard()will revert the internal buffer to the value of the data source.When in non-buffered mode both read and write operations will be done directly on the data source. In this mode the
Buffered.commit()andBuffered.discard()methods serve no purpose.- Specified by:
setBufferedin interfaceBuffered- Parameters:
buffered- true if buffered mode should be turned on, false otherwise
-
isBuffered
default boolean isBuffered()Description copied from interface:BufferedChecks the buffered mode- Specified by:
isBufferedin interfaceBuffered- Returns:
- true if buffered mode is on, false otherwise
-
isModified
default boolean isModified()Description copied from interface:BufferedTests if the value stored in the object has been modified since it was last updated from the data source.- Specified by:
isModifiedin interfaceBuffered- Returns:
trueif the value in the object has been modified since the last data source update,falseif not.
-
addValidator
Description copied from interface:ValidatableAdds a new validator for this object. The validator's
Validator.validate(Object)method is activated every time the object's value needs to be verified, that is, when theValidatable.isValid()method is called. This usually happens when the object's value changes.- Specified by:
addValidatorin interfaceValidatable- Parameters:
validator- the new validator
-
removeValidator
Description copied from interface:ValidatableRemoves a previously registered validator from the object. The specified validator is removed from the object and its
validatemethod is no longer called inValidatable.isValid().- Specified by:
removeValidatorin interfaceValidatable- Parameters:
validator- the validator to remove
-
removeAllValidators
default void removeAllValidators()Description copied from interface:ValidatableRemoves all validators from this object, as ifremoveValidatorwas called for each registered validator.- Specified by:
removeAllValidatorsin interfaceValidatable
-
getValidators
Description copied from interface:ValidatableReturns a collection of all validators currently registered for the object. The collection may be immutable. Calling
removeValidatorfor this Validatable while iterating over the collection may be unsafe (e.g. may throwConcurrentModificationException.)- Specified by:
getValidatorsin interfaceValidatable- Returns:
- A collection of validators
-
isValid
default boolean isValid()Description copied from interface:ValidatableTests the current value of the object against all registered validators. The registered validators are iterated and for each the
Validator.validate(Object)method is called. If any validator throws theValidator.InvalidValueExceptionthis method returnsfalse.- Specified by:
isValidin interfaceValidatable- Returns:
trueif the registered validators concur that the value is valid,falseotherwise
-
isInvalidAllowed
default boolean isInvalidAllowed()Description copied from interface:ValidatableChecks the validabtable object accept invalid values.The default value is
true.- Specified by:
isInvalidAllowedin interfaceValidatable
-
setInvalidAllowed
Description copied from interface:ValidatableShould the validabtable object accept invalid values. Supporting this configuration possibility is optional. By default invalid values are allowed.
- Specified by:
setInvalidAllowedin interfaceValidatable- Parameters:
invalidValueAllowed-- Throws:
UnsupportedOperationException- if the setInvalidAllowed is not supported.
-
isPropertyReadOnly
default boolean isPropertyReadOnly()Description copied from interface:PropertyTests if the Property is in read-only mode. In read-only mode calls to the methodsetValuewill throwReadOnlyExceptionand will not modify the value of the Property.- Specified by:
isPropertyReadOnlyin interfaceProperty<T>- Returns:
trueif the Property is in read-only mode,falseif it's not
-
setPropertyReadOnly
default void setPropertyReadOnly(boolean newStatus) Description copied from interface:PropertySets the Property's read-only mode to the specified status. This functionality is optional, but all properties must implement theisReadOnlymode query correctly.- Specified by:
setPropertyReadOnlyin interfaceProperty<T>- Parameters:
newStatus- new read-only status of the Property
-
addValueChangeListener
Description copied from interface:Property.ValueChangeNotifierRegisters a new value change listener for this Property.- Specified by:
addValueChangeListenerin interfaceProperty.ValueChangeNotifier- Parameters:
arg0- the new Listener to be registered
-
removeValueChangeListener
Description copied from interface:Property.ValueChangeNotifierRemoves a previously registered value change listener.- Specified by:
removeValueChangeListenerin interfaceProperty.ValueChangeNotifier- Parameters:
arg0- listener to be removed
-
valueChange
Description copied from interface:Property.ValueChangeListenerNotifies this listener that the Property's value has changed.- Specified by:
valueChangein interfaceProperty.ValueChangeListener- Parameters:
arg0- value change event object
-
setPropertyDataSource
Description copied from interface:Property.ViewerSets the Property that serves as the data source of the viewer.- Specified by:
setPropertyDataSourcein interfaceProperty.Viewer- Parameters:
newDataSource- the new data source Property
-
getPropertyDataSource
Description copied from interface:Property.ViewerGets the Property serving as the data source of the viewer.- Specified by:
getPropertyDataSourcein interfaceProperty.Viewer- Returns:
- the Property serving as the viewers data source
-
getType
Description copied from interface:PropertyReturns the type of the Property. The methodsgetValueandsetValuemust be compatible with this type: one must be able to safely cast the value returned fromgetValueto the given type and pass any variable assignable to this type as an argument tosetValue. -
addReadOnlyStatusChangeListener
Description copied from interface:Property.ReadOnlyStatusChangeNotifierRegisters a new read-only status change listener for this Property.- Specified by:
addReadOnlyStatusChangeListenerin interfaceProperty.ReadOnlyStatusChangeNotifier- Parameters:
arg0- the new Listener to be registered
-
removeReadOnlyStatusChangeListener
Description copied from interface:Property.ReadOnlyStatusChangeNotifierRemoves a previously registered read-only status change listener.- Specified by:
removeReadOnlyStatusChangeListenerin interfaceProperty.ReadOnlyStatusChangeNotifier- Parameters:
arg0- listener to be removed
-
readOnlyStatusChange
Description copied from interface:Property.ReadOnlyStatusChangeListenerNotifies this listener that a Property's read-only status has changed.- Specified by:
readOnlyStatusChangein interfaceProperty.ReadOnlyStatusChangeListener- Parameters:
arg0- Read-only status change event object
-