com.vaadin.ui.
Class AbstractDateField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>,R extends Enum<R>>
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.ui.AbstractComponent
-
- com.vaadin.ui.AbstractField<T>
-
- com.vaadin.ui.AbstractDateField<T,R>
-
Type Parameters:
T
- type of date (LocalDate
orLocalDateTime
).R
- resolution enumeration typeAll Implemented Interfaces:
HasValue<T>
,ContextClickEvent.ContextClickNotifier
,FieldEvents.BlurNotifier
,FieldEvents.FocusNotifier
,MethodEventSource
,ClientConnector
,Sizeable
,Connector
,Component
,Component.Focusable
,Serializable
Direct Known Subclasses:
public abstract class AbstractDateField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>,R extends Enum<R>> extends AbstractField<T> implements FieldEvents.FocusNotifier, FieldEvents.BlurNotifier
A date editor component with
LocalDate
as an input value.Since:
8.0
Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.data.HasValue
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<V>
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Constructor Summary
Constructors Constructor Description AbstractDateField(String caption, R resolution)
Constructs an empty
AbstractDateField
with caption.AbstractDateField(String caption, T value, R resolution)
Constructs a new
AbstractDateField
with the given caption and initial text contents.AbstractDateField(R resolution)
Constructs an empty
AbstractDateField
with no caption and specifiedresolution
.
-
Method Summary
All Methods Modifier and Type Method Description Registration
addBlurListener(FieldEvents.BlurListener listener)
Adds a
BlurListener
to the Component which gets fired when aField
loses keyboard focus.Registration
addFocusListener(FieldEvents.FocusListener listener)
Adds a
FocusListener
to the Component which gets fired when aField
receives keyboard focus.protected abstract T
adjustToResolution(T date, R resolution)
Adjusts the given date to the given resolution.
protected boolean
afterDate(T value, T base)
Checks if
value
is afterbase
or not.void
beforeClientResponse(boolean initial)
Called before the shared state and RPC invocations are sent to the client.
protected abstract T
buildDate(Map<R,Integer> resolutionValues)
Builds date by the given
resolutionValues
which is a map whose keys are resolution and integer values.protected abstract T
convertFromDate(Date date)
Converts
Date
to date typeT
.protected T
convertFromDateString(String temporalStr)
Parses string representation of date range limit into date type.
protected abstract Date
convertToDate(T date)
Converts the object of type
T
toDate
.protected String
convertToDateString(T temporal)
Converts date range limit into string representation.
protected void
doSetValue(T value)
Sets the value of this field.
protected abstract String
formatDate(T value)
Formats date according to the components locale.
void
getAssistiveLabel(AbstractDateFieldState.AccessibleElement element)
Gets the assistive label of a calendar navigation element.
String
getDateFormat()
Returns a format string used to format date value on client side or
null
if default formatting fromComponent.getLocale()
is used.String
getDateOutOfRangeMessage()
Returns current date-out-of-range error message.
protected abstract int
getDatePart(T date, R resolution)
Returns a date integer value part for the given
date
for the givenresolution
.String
getDateStyle(LocalDate date)
Returns the custom style name that corresponds with the given date's calendar cell.
Map<LocalDate,String>
getDateStyles()
Returns a map from dates to custom style names in each date's calendar cell.
Validator<T>
getDefaultValidator()
Returns a validator that checks the internal state of the HasValue.
T
getDefaultValue()
Returns the current default value.
String
getParseErrorMessage()
Return the error message that is shown if the user inputted value can't be parsed into a Date object.
T
getRangeEnd()
Returns the precise rangeEnd used.
T
getRangeStart()
Returns the precise rangeStart used.
protected abstract RangeValidator<T>
getRangeValidator()
Returns a custom date range validator which is applicable for the type
T
.R
getResolution()
Gets the resolution.
protected AbstractDateFieldState
getState()
Returns the shared state bean with information to be sent from the server to the client.
protected AbstractDateFieldState
getState(boolean markAsDirty)
Returns the shared state for this connector.
T
getValue()
Returns the current value of this object.
ZoneId
getZoneId()
Returns the
ZoneId
, which is used whenz
is included inside thesetDateFormat(String)
.protected Result<T>
handleUnparsableDateString(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.
boolean
isLenient()
Returns whether date/time interpretation is lenient.
boolean
isPreventInvalidInput()
Check whether value change is emitted when user input value does not meet integrated range validator.
boolean
isShowISOWeekNumbers()
Checks whether ISO 8601 week numbers are shown in the date selector.
void
readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Reads the component state from the given design.
protected T
reconstructDateFromFields(Map<String,Integer> resolutions, T oldDate)
Construct a date object from the individual field values received from the client.
void
setAssistiveLabel(AbstractDateFieldState.AccessibleElement element, String label)
Sets the assistive label for a calendar navigation element.
void
setDateFormat(String dateFormat)
Sets formatting used by some component implementations.
void
setDateOutOfRangeMessage(String dateOutOfRangeMessage)
Sets the current error message if the range validation fails.
void
setDateStyle(LocalDate date, String styleName)
Sets a custom style name for the given date's calendar cell.
void
setDaylightSavingTimeRange(int startYear, int endYear)
Sets
startYear
andendYear
: the start and end years (both inclusive) between which to calculate the daylight-saving time zone transition dates.void
setDefaultValue(T defaultValue)
Sets the default value for the field.
void
setLenient(boolean lenient)
Specifies whether or not date/time interpretation in component is to be lenient.
void
setLocale(Locale locale)
Sets the locale of this component.
void
setParseErrorMessage(String parsingErrorMessage)
Sets the default error message used if the DateField cannot parse the text input by user to a Date field.
void
setPreventInvalidInput(boolean preventInvalidInput)
Control whether value change event is emitted when user input value does not meet the integrated range validator.
void
setRangeEnd(T endDate)
Sets the end range for this component.
void
setRangeStart(T startDate)
Sets the start range for this component.
void
setResolution(R resolution)
Sets the resolution of the DateField.
void
setShowISOWeekNumbers(boolean showWeekNumbers)
Sets the visibility of ISO 8601 week numbers in the date selector.
void
setValue(T value)
Sets the value of this object.
void
setZoneId(ZoneId zoneId)
Sets the
ZoneId
, which is used whenz
is included inside thesetDateFormat(String)
.protected abstract T
toType(TemporalAccessor temporalAccessor)
Converts a temporal value into field-specific data type.
void
writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Writes the component state to the given design.
-
Methods inherited from class com.vaadin.ui.AbstractField
addValueChangeListener, createValueChange, focus, getCustomAttributes, getTabIndex, isDifferentValue, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible, setTabIndex, setValue
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.data.HasValue
clear, getEmptyValue, getOptionalValue, isEmpty
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefined
-
-
-
-
Constructor Detail
-
AbstractDateField
public AbstractDateField(R resolution)
Constructs an empty
AbstractDateField
with no caption and specifiedresolution
.Parameters:
resolution
- initial resolution for the field, notnull
-
AbstractDateField
public AbstractDateField(String caption, R resolution)
Constructs an empty
AbstractDateField
with caption.Parameters:
caption
- the caption of the datefieldresolution
- initial resolution for the field, notnull
-
AbstractDateField
public AbstractDateField(String caption, T value, R resolution)
Constructs a new
AbstractDateField
with the given caption and initial text contents.Parameters:
caption
- the captionString
for the editor.value
- the date/time value.resolution
- initial resolution for the field, notnull
-
-
Method Detail
-
beforeClientResponse
public void beforeClientResponse(boolean initial)
Description copied from interface:
ClientConnector
Called before the shared state and RPC invocations are sent to the client. Gives the connector an opportunity to set computed/dynamic state values or to invoke last minute RPC methods depending on other component features.
Specified by:
beforeClientResponse
in interfaceClientConnector
Overrides:
beforeClientResponse
in classAbstractComponent
Parameters:
initial
-true
if the client-side connector will be created and initialized after this method has been invoked.false
if there is already an initialized client-side connector.
-
reconstructDateFromFields
protected T reconstructDateFromFields(Map<String,Integer> resolutions, T oldDate)
Construct a date object from the individual field values received from the client.
Parameters:
resolutions
- map of time unit (resolution) name and value, the key is the resolution name e.g. "HOUR", "MINUTE", the value can benull
oldDate
- used as a fallback to get needed values if they are not defined in the specifiedresolutions
Returns:
the date object built from the specified resolutions
Since:
8.2
-
setRangeStart
public void setRangeStart(T startDate)
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. If
startDate
is set tonull
, any value beforeendDate
will be accepted by the rangeNote: Negative, i.e. BC dates are not supported.
Note: It's usually recommended to use only one of the following at the same time: Range validator with Binder or DateField's setRangeStart check.
Parameters:
startDate
- - the allowed range's start date
-
setDateOutOfRangeMessage
public void setDateOutOfRangeMessage(String dateOutOfRangeMessage)
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
-
getDateOutOfRangeMessage
public String getDateOutOfRangeMessage()
Returns current date-out-of-range error message.
Returns:
Current error message for dates out of range.
See Also:
-
getResolution
public R getResolution()
Gets the resolution.
Returns:
the date/time field resolution
-
setResolution
public void setResolution(R resolution)
Sets the resolution of the DateField. The default resolution is
DateResolution.DAY
since Vaadin 7.0.Parameters:
resolution
- the resolution to set, notnull
-
setRangeEnd
public void setRangeEnd(T endDate)
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. If
endDate
is set tonull
, any value afterstartDate
will be accepted by the range.Note: It's usually recommended to use only one of the following at the same time: Range validator with Binder or DateField's setRangeEnd check.
Parameters:
endDate
- the allowed range's end date (inclusive, based on the current resolution)
-
getRangeStart
public T getRangeStart()
Returns the precise rangeStart used.
Returns:
the precise rangeStart used, may be
null
.
-
convertFromDateString
protected T convertFromDateString(String temporalStr)
Parses string representation of date range limit into date type.
Parameters:
temporalStr
- the string representationReturns:
parsed value
Since:
8.4
See Also:
AbstractDateFieldState.rangeStart
,AbstractDateFieldState.rangeEnd
-
toType
protected abstract T toType(TemporalAccessor temporalAccessor)
Converts a temporal value into field-specific data type.
Parameters:
temporalAccessor
- - source valueReturns:
conversion result.
Since:
8.4
-
convertToDateString
protected String convertToDateString(T temporal)
Converts date range limit into string representation.
Parameters:
temporal
- the valueReturns:
textual representation
Since:
8.4
See Also:
AbstractDateFieldState.rangeStart
,AbstractDateFieldState.rangeEnd
-
afterDate
protected boolean afterDate(T value, T base)
Checks if
value
is afterbase
or not.Parameters:
value
- temporal valuebase
- temporal value to compare toReturns:
true
ifvalue
is afterbase
,false
otherwise
-
getRangeEnd
public T getRangeEnd()
Returns the precise rangeEnd used.
Returns:
the precise rangeEnd used, may be
null
.
-
setDateFormat
public void setDateFormat(String dateFormat)
Sets formatting used by some component implementations. See
SimpleDateFormat
for 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, can benull
See Also:
-
getDateFormat
public String 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
-
setZoneId
public void setZoneId(ZoneId zoneId)
Sets the
ZoneId
, which is used whenz
is included inside thesetDateFormat(String)
.Parameters:
zoneId
- the zone idSince:
8.2
-
setDaylightSavingTimeRange
public void setDaylightSavingTimeRange(int startYear, int endYear)
Sets
startYear
andendYear
: the start and end years (both inclusive) between which to calculate the daylight-saving time zone transition dates. Both parameters are used when 'z
' is included inside thesetDateFormat(String)
, they would have no effect otherwise. Specifically, these parameters determine the range of years in which zone names are are adjusted to show the daylight saving names. If no values are provided, by defaultstartYear
is set to 1980, andendYear
is set to 20 years into the future from the current date.Parameters:
startYear
- the start year of DST transitionsendYear
- the end year of DST transitionsSince:
8.11
-
setLocale
public void setLocale(Locale locale)
Description copied from class:
AbstractComponent
Sets 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);
Overrides:
setLocale
in classAbstractComponent
Parameters:
locale
- the locale to become this component's locale.
-
getZoneId
public ZoneId getZoneId()
Returns the
ZoneId
, which is used whenz
is included inside thesetDateFormat(String)
.Returns:
the zoneId
Since:
8.2
-
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 lenient.
Returns:
true
if the interpretation mode of this calendar is lenient;false
otherwise.See Also:
-
getValue
public T getValue()
Description copied from interface:
HasValue
Returns the current value of this object.
Implementation note: the implementing class should document whether null values may be returned or not.
Specified by:
getValue
in interfaceHasValue<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>
Returns:
the current value
-
getDefaultValue
public T getDefaultValue()
Returns the current default value.
Returns:
the default value
Since:
8.1.2
See Also:
-
setDefaultValue
public void setDefaultValue(T defaultValue)
Sets the default value for the field. The default value is the starting point for the date field when nothing has been selected yet. If no default value is set, current date/time is used.
Parameters:
defaultValue
- the default value, may benull
Since:
8.1.2
-
setValue
public void setValue(T value)
Sets the value of this object. If the new value is not equal to
getValue()
, fires aHasValue.ValueChangeEvent
.Specified by:
setValue
in interfaceHasValue<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>
Overrides:
setValue
in classAbstractField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>
Parameters:
value
- the new value, may benull
Throws:
IllegalArgumentException
- if the value is not within range bounds
-
adjustToResolution
protected abstract T adjustToResolution(T date, R resolution)
Adjusts the given date to the given resolution. Any values that are more specific than the given resolution are truncated to their default values.
Parameters:
date
- the date to adjust, can benull
resolution
- the resolution to be used in the adjustment, can benull
Returns:
an adjusted date that matches the given resolution, or
null
if the given date, resolution, or both werenull
-
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
public String getParseErrorMessage()
Return the error message that is shown if the user inputted value can't be parsed into a Date object. If
handleUnparsableDateString(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
public void setParseErrorMessage(String parsingErrorMessage)
Sets the default error message used if the DateField cannot parse the text input by user to a Date field. Note that if the
handleUnparsableDateString(String)
method is overridden, the localized message from its exception is used.Parameters:
parsingErrorMessage
- the default parsing error messageSee Also:
-
addFocusListener
public Registration addFocusListener(FieldEvents.FocusListener listener)
Description copied from interface:
FieldEvents.FocusNotifier
Adds a
FocusListener
to the Component which gets fired when aField
receives keyboard focus.Specified by:
addFocusListener
in interfaceFieldEvents.FocusNotifier
Parameters:
listener
- the focus listener to add, not nullReturns:
a registration object for removing the listener
See Also:
-
addBlurListener
public Registration addBlurListener(FieldEvents.BlurListener listener)
Description copied from interface:
FieldEvents.BlurNotifier
Adds a
BlurListener
to the Component which gets fired when aField
loses keyboard focus.Specified by:
addBlurListener
in interfaceFieldEvents.BlurNotifier
Parameters:
listener
- the blur listener to add, not nullReturns:
a registration object for removing the listener
See Also:
-
readDesign
public void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Description copied from interface:
Component
Reads the component state from the given design.
The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.
It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.
This method must not modify the design.
Specified by:
readDesign
in interfaceComponent
Overrides:
readDesign
in classAbstractField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>
Parameters:
design
- The element to obtain the state fromdesignContext
- The DesignContext instance used for parsing the design
-
formatDate
protected abstract String formatDate(T value)
Formats date according to the components locale.
Parameters:
value
- the date ornull
Returns:
textual representation of the date or empty string for
null
Since:
8.1.1
-
writeDesign
public void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Description copied from interface:
Component
Writes the component state to the given design.
The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.
This method must not modify the component state.
Specified by:
writeDesign
in interfaceComponent
Overrides:
writeDesign
in classAbstractField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>
Parameters:
design
- The element to write the component state to. Any previous attributes or child nodes are not cleared.designContext
- The DesignContext instance used for writing the design
-
handleUnparsableDateString
protected Result<T> handleUnparsableDateString(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. By default, an error result is returned whose error message is
getParseErrorMessage()
. This can be overridden to handle conversions, to return a result withnull
value (equivalent to empty input) or to return a custom error.Parameters:
dateString
- date string to handleReturns:
result that contains parsed Date as a value or an error
-
getState
protected AbstractDateFieldState getState()
Description copied from class:
AbstractComponent
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().
Overrides:
getState
in classAbstractField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>
Returns:
updated component shared state
-
getState
protected AbstractDateFieldState getState(boolean markAsDirty)
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector.
Overrides:
getState
in classAbstractField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>
Parameters:
markAsDirty
- true if the connector should automatically be marked dirty, false otherwiseReturns:
The shared state for this connector. Never null.
See Also:
-
doSetValue
protected void doSetValue(T value)
Description copied from class:
AbstractField
Sets the value of this field. May do sanitization or throw
IllegalArgumentException
if the value is invalid. Typically saves the value to shared state.Specified by:
doSetValue
in classAbstractField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>
Parameters:
value
- the new value of the field
-
getDatePart
protected abstract int getDatePart(T date, R resolution)
Returns a date integer value part for the given
date
for the givenresolution
.Parameters:
date
- the given date, can benull
resolution
- the resolution to extract a value from the date by, notnull
Returns:
the integer value part of the date by the given resolution
-
buildDate
protected abstract T buildDate(Map<R,Integer> resolutionValues)
Builds date by the given
resolutionValues
which is a map whose keys are resolution and integer values.This is the opposite to
getDatePart(Temporal, Enum)
.Parameters:
resolutionValues
- date values to construct a dateReturns:
date built from the given map of date values
-
getRangeValidator
protected abstract RangeValidator<T> getRangeValidator()
Returns a custom date range validator which is applicable for the type
T
.Returns:
the date range validator
-
convertFromDate
protected abstract T convertFromDate(Date date)
Converts
Date
to date typeT
.Parameters:
date
- a date to convertReturns:
object of type
T
representing thedate
-
convertToDate
protected abstract Date convertToDate(T date)
Converts the object of type
T
toDate
.This is the opposite to
convertFromDate(Date)
.Parameters:
date
- the date of typeT
Returns:
converted date of type
Date
-
getDefaultValidator
public Validator<T> getDefaultValidator()
Description copied from interface:
HasValue
Returns a validator that checks the internal state of the HasValue. This should be overridden for components with internal value conversion or validation, e.g. when the user is providing a string that has to be parsed into a date. An invalid input from user will be exposed to a
Binder
and can be seen as a validation failure.Specified by:
getDefaultValidator
in interfaceHasValue<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>
Returns:
internal state validator
See Also:
-
setDateStyle
public void setDateStyle(LocalDate date, String styleName)
Sets a custom style name for the given date's calendar cell. Setting the style name will override any previous style names that have been set for that date, but can contain several actual style names separated by space. Setting the custom style name
null
will only remove the previous custom style name.This logic is entirely separate from
AbstractComponent.setStyleName(String)
Usage examples:
setDateStyle(LocalDate.now(), "teststyle");
setDateStyle(LocalDate.now(), "teststyle1 teststyle2");
Parameters:
date
- which date cell to modify, notnull
styleName
- the custom style name(s) for given date,null
to clear custom style name(s)Since:
8.3
-
getDateStyle
public String getDateStyle(LocalDate date)
Returns the custom style name that corresponds with the given date's calendar cell.
Parameters:
date
- which date cell's custom style name(s) to return, notnull
Returns:
the corresponding style name(s), if any,
null
otherwiseSince:
8.3
See Also:
-
getDateStyles
public Map<LocalDate,String> getDateStyles()
Returns a map from dates to custom style names in each date's calendar cell.
Returns:
unmodifiable map from dates to custom style names in each date's calendar cell
Since:
8.3
See Also:
-
setAssistiveLabel
public void setAssistiveLabel(AbstractDateFieldState.AccessibleElement element, String label)
Sets the assistive label for a calendar navigation element. This sets the
aria-label
attribute for the element which is used by screen reading software.Parameters:
element
- the element for which to set the label. Notnull
.label
- the assistive label to setSince:
8.4
-
getAssistiveLabel
public void getAssistiveLabel(AbstractDateFieldState.AccessibleElement element)
Gets the assistive label of a calendar navigation element.
Parameters:
element
- the element of which to get the assistive labelSince:
8.4
-
setPreventInvalidInput
public void setPreventInvalidInput(boolean preventInvalidInput)
Control whether value change event is emitted when user input value does not meet the integrated range validator.
Parameters:
preventInvalidInput
- Set to false to disable the value change event.Since:
8.13
-
isPreventInvalidInput
public boolean isPreventInvalidInput()
Check whether value change is emitted when user input value does not meet integrated range validator. The default is false.
Returns:
a Boolean value
Since:
8.13
-
-