Class FDateField
- All Implemented Interfaces:
Buffered,BufferedValidatable,Property<Date>,Property.Editor,Property.ReadOnlyStatusChangeListener,Property.ReadOnlyStatusChangeNotifier,Property.ValueChangeListener,Property.ValueChangeNotifier,Property.Viewer,Field<Date>,Validatable,FieldEvents.BlurNotifier,FieldEvents.FocusNotifier,ClientConnector,FAbstractClientConnector,FSizeable,HasSizeable,FAbstractComponent,com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.customfield.CustomField<Date>>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<com.vaadin.flow.component.customfield.CustomField<Date>>,com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.customfield.CustomField<Date>>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasHelper,com.vaadin.flow.component.HasLabel,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.HasValidation,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<Date>,,Date>, Date> com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<Date>,,Date>, Date> com.vaadin.flow.component.shared.HasTooltip,com.vaadin.flow.component.shared.HasValidationProperties,com.vaadin.flow.component.shared.InputField<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<Date>,,Date>, Date> Serializable
A date editor component that can be bound to any Property that is
compatible with java.util.Date.
Since DateField implements FAbstractField and it
implements the Buffered interface.
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V> Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.featurepack.data.Buffered
Buffered.SourceExceptionNested classes/interfaces inherited from interface com.vaadin.featurepack.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.DetachEvent, ClientConnector.DetachListenerNested classes/interfaces inherited from interface com.vaadin.featurepack.server.FAbstractClientConnector
FAbstractClientConnector.LegacyMethodEventNested classes/interfaces inherited from interface com.vaadin.featurepack.ui.FAbstractComponent
FAbstractComponent.DataKeyNested classes/interfaces inherited from interface com.vaadin.featurepack.data.ui.Field
Field.ValueChangeEventNested classes/interfaces inherited from interface com.vaadin.flow.component.Focusable
com.vaadin.flow.component.Focusable.FocusJsNested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>>Nested 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 -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an emptyFDateFieldwith no caption.FDateField(Property dataSource) Constructs a newFDateFieldthat's bound to the specifiedPropertyand has no caption.FDateField(String caption) Constructs an emptyFDateFieldwith caption.FDateField(String caption, Property dataSource) Constructs a newFDateFieldthat's bound to the specifiedPropertyand has the given captionString.FDateField(String caption, Date value) Constructs a newFDateFieldwith the given caption and initial text contents. -
Method Summary
Modifier and TypeMethodDescriptionvoiddiscard()Discards all changes since last commit.protected voidfireEvent(com.vaadin.flow.component.ComponentEvent<?> componentEvent) protected DateReturns a format string used to format date value on client side or null if default formatting fromComponent.getLocale()is used.Returns current date-out-of-range error message.Return the error message that is shown if the user inputted value can't be parsed into a Date object.Returns the precise rangeEnd used.Returns the precise rangeStart used.Gets the resolution.getStep()Gets the step of the time picker.Gets the time zone used by this field.getType()Returns the type of the Property.getValue()Gets the value stored in the Property.protected DatehandleUnparsableDateString(String dateString) This method is called to handle a non-empty date string from the client if the client could not parse it as a Date.booleanReturns whether date/time interpretation is to be lenient.booleanChecks whether ISO 8601 week numbers are shown in the date selector.booleanisValid()Tests the current value of the object against all registered validators.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonDetach(com.vaadin.flow.component.DetachEvent detachEvent) voidsetDateFormat(String dateFormat) Sets formatting used by some component implementations.voidsetDateOutOfRangeMessage(String dateOutOfRangeMessage) Sets the current error message if the range validation fails.voidsetLabelComponent(com.vaadin.flow.component.Component labelComponent) Sets the component's label component.voidsetLenient(boolean lenient) Specifies whether or not date/time interpretation in component is to be lenient.voidSets the locale of this component.voidsetParseErrorMessage(String parsingErrorMessage) Sets the default error message used if the DateField cannot parse the text input by user to a Date field.protected voidsetPresentationValue(Date date) voidsetRangeEnd(Date endDate) Sets the end range for this component.voidsetRangeStart(Date startDate) Sets the start range for this component.voidsetReadOnly(boolean readOnly) voidsetResolution(Resolution resolution) Sets the resolution of the DateField.voidsetShowISOWeekNumbers(boolean showWeekNumbers) Sets the visibility of ISO 8601 week numbers in the date selector.voidSets the step of the time picker.voidsetTimeZone(TimeZone timeZone) Sets the time zone used by this date field.voidSets the value of the Property.protected booleanReturns true if the error indicator be hidden when painting the component even when there are errors.voidvalidate()Checks the validity of the validatable.Methods inherited from class com.vaadin.flow.component.customfield.CustomField
add, addThemeVariants, getLabel, remove, removeThemeVariants, setLabel, updateValueMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, bindValue, getEmptyValue, isEmpty, setModelValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, findAncestor, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, getUIOrThrow, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttachedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.featurepack.server.FAbstractClientConnector
addLegacyAttachListener, addLegacyDetachListener, addListener, addListener, attach, detach, doConnectorOnAttach, doConnectorOnDetach, fireEvent, fireEvent, getAllChildrenIterable, getFListeners, getFlowComponent, getResource, hasListeners, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeListener, removeListener, setResourceMethods inherited from interface com.vaadin.featurepack.ui.FAbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, addStyleNames, beforeClientResponse, getCaption, getComponentError, getData, getDescription, getFErrorIndicator, getFErrorMessage, getFId, getFParent, getIcon, getIconResource, getPrimaryStyleName, getStyleName, isCaptionAsHtml, isImmediate, isResponsive, notifyParentAboutStyleChanges, removeContextClickListener, removeShortcutListener, removeStyleName, removeStyleNames, setCaption, setCaptionAsHtml, setComponentError, setData, setDescription, setDescription, setIcon, setIcon, setIconResource, setImmediate, setPrimaryStyleName, setResponsive, setStyleName, setStyleNameMethods inherited from interface com.vaadin.featurepack.data.ui.Field
addReadOnlyStatusChangeListener, addValidator, addValueChangeListener, commit, getConvertedValue, getConverter, getFAbstractField, getPropertyDataSource, getRequiredError, getValidators, isBuffered, isEmpty, isInvalidAllowed, isInvalidCommitted, isModified, isPropertyReadOnly, isRequired, readOnlyStatusChange, removeAllValidators, removeReadOnlyStatusChangeListener, removeValidator, removeValueChangeListener, setBuffered, setConverter, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setPropertyReadOnly, setRequired, setRequiredError, valueChangeMethods inherited from interface com.vaadin.featurepack.event.FieldEvents.BlurNotifier
addBlurListener, removeBlurListenerMethods inherited from interface com.vaadin.featurepack.event.FieldEvents.FocusNotifier
addFocusListener, removeFocusListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasHelper
bindHelperText, getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.featurepack.server.HasSizeable
getFHeight, getFWidth, getHeightUnits, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefinedMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipMarkdown, setTooltipTextMethods inherited from interface com.vaadin.flow.component.HasValidation
setManualValidationMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, isInvalid, setErrorMessage, setInvalidMethods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, bindValue, clear, getEmptyValue, getOptionalValue, isEmptyMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
bindReadOnly, bindRequiredIndicatorVisible, isReadOnly, isRequiredIndicatorVisible, setRequiredIndicatorVisible
-
Constructor Details
-
FDateField
public FDateField()Constructs an emptyFDateFieldwith no caption. -
FDateField
Constructs an emptyFDateFieldwith caption.- Parameters:
caption- the caption of the datefield.
-
FDateField
Constructs a newFDateFieldthat's bound to the specifiedPropertyand has the given captionString.- Parameters:
caption- the captionStringfor the editor.dataSource- the Property to be edited with this editor.
-
FDateField
Constructs a newFDateFieldthat's bound to the specifiedPropertyand has no caption.- Parameters:
dataSource- the Property to be edited with this editor.- Throws:
IllegalArgumentException
-
FDateField
Constructs a newFDateFieldwith the given caption and initial text contents. The editor constructed this way will not be bound to a Property unlessProperty.Viewer.setPropertyDataSource(Property)is called to bind it.- Parameters:
caption- the captionStringfor the editor.value- the Date value.
-
-
Method Details
-
setLabelComponent
public void setLabelComponent(com.vaadin.flow.component.Component labelComponent) Description copied from interface:FAbstractComponentSets the component's label component. Flow components that support caption component usually overrides this.- Specified by:
setLabelComponentin interfaceFAbstractComponent- Parameters:
labelComponent- the new label component for the component.
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
generateModelValue
- Specified by:
generateModelValuein classcom.vaadin.flow.component.customfield.CustomField<Date>
-
setPresentationValue
- Specified by:
setPresentationValuein classcom.vaadin.flow.component.customfield.CustomField<Date>
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetachin classcom.vaadin.flow.component.Component
-
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. -
validate
Description copied from interface:ValidatableChecks the validity of the validatable. If the validatable is valid this method should do nothing, and if it's not valid, it should throw
Validator.InvalidValueException- Specified by:
validatein interfaceValidatable- Throws:
Validator.InvalidValueException- if the value is not valid
-
isValid
public 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 interfaceField<Date>- Specified by:
isValidin interfaceValidatable- Returns:
trueif the registered validators concur that the value is valid,falseotherwise
-
getValue
Description copied from interface:PropertyGets the value stored in the Property. The returned object is compatible with the class returned by getType().- Specified by:
getValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<Date>,Date>, Date> - Specified by:
getValuein interfaceProperty<Date>- Overrides:
getValuein classcom.vaadin.flow.component.AbstractField<com.vaadin.flow.component.customfield.CustomField<Date>,Date> - Returns:
- the value stored in the Property
-
setValue
Description copied from interface:PropertySets the value of the Property.Implementing this functionality is optional. If the functionality is missing, one should declare the Property to be in read-only mode and throw
Note : Since Vaadin 7.0, setting the value of a non-String property as a String is no longer supported.Property.ReadOnlyExceptionin this function.- Specified by:
setValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<Date>,Date>, Date> - Specified by:
setValuein interfaceProperty<Date>- Overrides:
setValuein classcom.vaadin.flow.component.AbstractField<com.vaadin.flow.component.customfield.CustomField<Date>,Date> - Parameters:
value- New value of the Property. This should be assignable to the type returned by getType
-
shouldHideErrors
protected boolean shouldHideErrors()Returns true if the error indicator be hidden when painting the component even when there are errors. This is a mostly internal method, but can be overridden in subclasses e.g. if the error indicator should also be shown for empty fields in some cases.- Returns:
- true to hide the error indicator, false to use the normal logic to show it when there are errors
-
setRangeStart
Sets the start range for this component. If the value is set before this date (taking the resolution into account), the component will not validate. IfstartDateis set tonull, any value beforeendDatewill be accepted by the range- Parameters:
startDate- - the allowed range's start date
-
setDateOutOfRangeMessage
Sets the current error message if the range validation fails.- Parameters:
dateOutOfRangeMessage- - Localizable message which is shown when value (the date) is set outside allowed range
-
setRangeEnd
Sets the end range for this component. If the value is set after this date (taking the resolution into account), the component will not validate. IfendDateis set tonull, any value afterstartDatewill be accepted by the range.- Parameters:
endDate- - the allowed range's end date (inclusive, based on the current resolution)
-
getRangeStart
Returns the precise rangeStart used. -
getRangeEnd
Returns the precise rangeEnd used. -
discard
public void discard()Description copied from interface:BufferedDiscards all changes since last commit. The object updates its value from the data source. -
handleUnparsableDateString
This method is called to handle a non-empty date string from the client if the client could not parse it as a Date. By default, a Converter.ConversionException is thrown, and the current value is not modified. This can be overridden to handle conversions, to return null (equivalent to empty input), to throw an exception or to fire an event.- Parameters:
dateString-- Returns:
- parsed Date
- Throws:
Converter.ConversionException- to keep the old value and indicate an error
-
getResolution
Gets the resolution.- Returns:
- int
-
setDateFormat
Sets formatting used by some component implementations. SeeSimpleDateFormatfor format details. By default it is encouraged to used default formatting defined by Locale, but due some JVM bugs it is sometimes necessary to use this method to override formatting. See Vaadin issue #2200.- Parameters:
dateFormat- the dateFormat to set
-
getDateFormat
Returns a format string used to format date value on client side or null if default formatting fromComponent.getLocale()is used.- Returns:
- the dateFormat
-
setLenient
public void setLenient(boolean lenient) Specifies whether or not date/time interpretation in component is to be lenient.- Parameters:
lenient- true if the lenient mode is to be turned on; false if it is to be turned off.- See Also:
-
isLenient
public boolean isLenient()Returns whether date/time interpretation is to be lenient.- Returns:
- true if the interpretation mode of this calendar is lenient; false otherwise.
- See Also:
-
isShowISOWeekNumbers
public boolean isShowISOWeekNumbers()Checks whether ISO 8601 week numbers are shown in the date selector.- Returns:
- true if week numbers are shown, false otherwise.
-
setShowISOWeekNumbers
public void setShowISOWeekNumbers(boolean showWeekNumbers) Sets the visibility of ISO 8601 week numbers in the date selector. ISO 8601 defines that a week always starts with a Monday so the week numbers are only shown if this is the case.- Parameters:
showWeekNumbers- true if week numbers should be shown, false otherwise.
-
getParseErrorMessage
Return the error message that is shown if the user inputted value can't be parsed into a Date object. IfhandleUnparsableDateString(String)is overridden and it throws a custom exception, the message returned byThrowable.getLocalizedMessage()will be used instead of the value returned by this method.- Returns:
- the error message that the DateField uses when it can't parse the textual input from user to a Date object
- See Also:
-
setParseErrorMessage
Sets the default error message used if the DateField cannot parse the text input by user to a Date field. Note that if thehandleUnparsableDateString(String)method is overridden, the localized message from its exception is used.- Parameters:
parsingErrorMessage-- See Also:
-
setTimeZone
Sets the time zone used by this date field. The time zone is used to convert the absolute time in a Date object to a logical time displayed in the selector and to convert the select time back to a Date object. If no time zone has been set, the current default time zone returned byTimeZone.getDefault()is used.- Parameters:
timeZone- the time zone to use for time calculations.- See Also:
-
getTimeZone
Gets the time zone used by this field. The time zone is used to convert the absolute time in a Date object to a logical time displayed in the selector and to convert the select time back to a Date object. Ifnullis returned, the current default time zone returned byTimeZone.getDefault()is used.- Returns:
- the current time zone
-
getDateOutOfRangeMessage
Returns current date-out-of-range error message.- Returns:
- Current error message for dates out of range.
- Since:
- 7.4
- See Also:
-
setLocale
Description copied from interface:FAbstractComponentSets the locale of this component.// Component for which the locale is meaningful InlineDateField date = new InlineDateField("Datum"); // German language specified with ISO 639-1 language // code and ISO 3166-1 alpha-2 country code. date.setLocale(new Locale("de", "DE")); date.setResolution(DateField.RESOLUTION_DAY); layout.addComponent(date);- Specified by:
setLocalein interfaceFAbstractComponent- Parameters:
locale- the locale to become this component's locale.
-
setStep
Sets the step of the time picker. SeeDateTimePicker.setStep(Duration)for more information.- Parameters:
step- the step to set, notnulland should divide a day or an hour evenly- See Also:
-
getStep
Gets the step of the time picker.- Returns:
- the
stepproperty from the picker, unit seconds
-
setReadOnly
public void setReadOnly(boolean readOnly) - Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<Date>,Date>, Date> - Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<Date>,Date>, Date>
-
fireEvent
protected void fireEvent(com.vaadin.flow.component.ComponentEvent<?> componentEvent) - Overrides:
fireEventin classcom.vaadin.flow.component.Component
-