T - type of date (LocalDate or LocalDateTime).R - resolution enumeration typepublic abstract class AbstractDateField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>,R extends Enum<R>> extends AbstractField<T> implements LegacyComponent, FieldEvents.FocusNotifier, FieldEvents.BlurNotifier
LocalDate as an input value.Component.ErrorEvent, Component.Event, Component.Focusable, Component.ListenerClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListenerSizeable.UnitHasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<V>DESIGN_ATTR_PLAIN_TEXTSIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS| Constructor and Description |
|---|
AbstractDateField(R resolution)
Constructs an empty
AbstractDateField with no caption and
specified resolution. |
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. |
| Modifier and Type | Method and Description |
|---|---|
Registration |
addBlurListener(FieldEvents.BlurListener listener)
Adds a
BlurListener to the Component which gets fired
when a Field loses keyboard focus. |
Registration |
addFocusListener(FieldEvents.FocusListener listener)
Adds a
FocusListener to the Component which gets fired
when a Field receives keyboard focus. |
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. |
void |
changeVariables(Object source,
Map<String,Object> variables)
Called when one or more variables handled by the implementing class are
changed.
|
protected abstract T |
convertFromDate(Date date)
Converts
Date to date type T. |
protected abstract Date |
convertToDate(T date)
Converts the object of type
T to Date. |
protected void |
doSetValue(T value)
Sets the value of this field.
|
protected void |
fireEvent(EventObject event)
Sends the event to all listeners.
|
String |
getDateFormat()
Returns a format string used to format date value on client side or null
if default formatting from
Component.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
given resolution. |
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.
|
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 to be lenient.
|
boolean |
isShowISOWeekNumbers()
Checks whether ISO 8601 week numbers are shown in the date selector.
|
void |
paintContent(PaintTarget target)
Paints the Paintable into a UIDL stream.
|
void |
readDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Reads the component state from the given design.
|
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 |
setLenient(boolean lenient)
Specifies whether or not date/time interpretation in component is to be
lenient.
|
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 |
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 |
writeDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Writes the component state to the given design.
|
addValueChangeListener, createValueChange, focus, getCustomAttributes, getTabIndex, isDifferentValue, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible, setTabIndex, setValueaddContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, 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, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidth, setWidthUndefinedaddAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, 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, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstateclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitmarkAsDirtyisEnabledaddListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setVisibleaddAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdgetHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefinedclear, getEmptyValue, getOptionalValue, isEmptypublic AbstractDateField(R resolution)
AbstractDateField with no caption and
specified resolution.resolution - initial resolution for the fieldpublic AbstractDateField(String caption, R resolution)
AbstractDateField with caption.caption - the caption of the datefield.resolution - initial resolution for the fieldpublic void paintContent(PaintTarget target) throws PaintException
LegacyComponentPaints the Paintable into a UIDL stream. This method creates the UIDL sequence describing it and outputs it to the given UIDL stream.
It is called when the contents of the component should be painted in response to the component first being shown or having been altered so that its visual representation is changed.
paintContent in interface LegacyComponenttarget - the target UIDL stream where the component should paint itself
to.PaintException - if the paint operation failed.public void changeVariables(Object source, Map<String,Object> variables)
VariableOwnerchangeVariables in interface VariableOwnersource - the Source of the variable change. This is the origin of the
event. For example in Web Adapter this is the request.variables - the Mapping from variable names to new variable values.public void setRangeStart(T startDate)
startDate is set to null, any
value before endDate will be accepted by the rangestartDate - - the allowed range's start datepublic void setDateOutOfRangeMessage(String dateOutOfRangeMessage)
dateOutOfRangeMessage - - Localizable message which is shown when value (the date) is
set outside allowed rangepublic String getDateOutOfRangeMessage()
setDateOutOfRangeMessage(String)public R getResolution()
public void setResolution(R resolution)
DateResolution.DAY since Vaadin 7.0.resolution - the resolution to set, not nullpublic void setRangeEnd(T endDate)
endDate is set to null, any value
after startDate will be accepted by the range.endDate - - the allowed range's end date (inclusive, based on the
current resolution)public T getRangeStart()
public T getRangeEnd()
public void setDateFormat(String dateFormat)
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.dateFormat - the dateFormat to setcom.vaadin.ui.AbstractComponent#setLocale(Locale))public String getDateFormat()
Component.getLocale() is used.public void setLenient(boolean lenient)
lenient - true if the lenient mode is to be turned on; false if it is to
be turned off.Calendar.setLenient(boolean),
isLenient()public boolean isLenient()
setLenient(boolean)public T getValue()
HasValueImplementation note: the implementing class should document whether null values may be returned or not.
getValue in interface HasValue<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>public void setValue(T value)
getValue(), fires a ValueChangeEvent .setValue in interface HasValue<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>setValue in class AbstractField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>value - the new value, may be nullpublic boolean isShowISOWeekNumbers()
public void setShowISOWeekNumbers(boolean showWeekNumbers)
showWeekNumbers - true if week numbers should be shown, false otherwise.public String getParseErrorMessage()
handleUnparsableDateString(String) is overridden and it throws a
custom exception, the message returned by
Throwable.getLocalizedMessage() will be used instead of the value
returned by this method.setParseErrorMessage(String)public void setParseErrorMessage(String parsingErrorMessage)
handleUnparsableDateString(String) method is overridden, the
localized message from its exception is used.parsingErrorMessage - getParseErrorMessage(),
handleUnparsableDateString(String)public Registration addFocusListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifierFocusListener to the Component which gets fired
when a Field receives keyboard focus.addFocusListener in interface FieldEvents.FocusNotifierlistener - the focus listener to add, not nullFieldEvents.FocusListener,
Registrationpublic Registration addBlurListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifierBlurListener to the Component which gets fired
when a Field loses keyboard focus.addBlurListener in interface FieldEvents.BlurNotifierlistener - the blur listener to add, not nullFieldEvents.BlurListener,
Registrationpublic void readDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
ComponentThe 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.
readDesign in interface ComponentreadDesign in class AbstractField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>design - The element to obtain the state fromdesignContext - The DesignContext instance used for parsing the designpublic void writeDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
ComponentThe 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.
writeDesign in interface ComponentwriteDesign in class AbstractField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>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 designprotected void fireEvent(EventObject event)
AbstractClientConnectorfireEvent in class AbstractClientConnectorevent - the Event to be sent to all listeners.protected Result<T> handleUnparsableDateString(String dateString)
getParseErrorMessage().
This can be overridden to handle conversions, to return a result with
null value (equivalent to empty input) or to return a custom
error.dateString - date string to handleprotected AbstractDateFieldState getState()
AbstractComponentgetState in class AbstractField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>protected AbstractDateFieldState getState(boolean markAsDirty)
AbstractClientConnectorgetState in class AbstractField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>markAsDirty - true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()protected void doSetValue(T value)
AbstractFieldIllegalArgumentException if the value is invalid. Typically saves
the value to shared state.doSetValue in class AbstractField<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>>value - the new value of the fieldprotected abstract int getDatePart(T date, R resolution)
date for the
given resolution.date - the given dateresolution - the resolution to extract a value from the date byprotected abstract T buildDate(Map<R,Integer> resolutionValues)
resolutionValues which is a map whose
keys are resolution and integer values.
This is the opposite to getDatePart(Temporal, Enum).
resolutionValues - date values to construct a dateprotected abstract RangeValidator<T> getRangeValidator()
T.protected abstract T convertFromDate(Date date)
Date to date type T.date - a date to convertT representing the dateCopyright © 2017 Vaadin Ltd. All rights reserved.