Class WDateEdit
- java.lang.Object
-
public class WDateEdit extends WLineEdit
A date edit.A date picker is a line edit with support for date entry (using an icon and a calendar).
A
WDateValidatoris used to validate date entry.In many cases, it provides a more convenient implementation of a date picker compared to
WDatePickersince it is implemented as a line edit, and aWDateEditcan be configured as anative HTML5 control.When the native HTML5 control is used, the format is limited to
yyyy-MM-dd. Changing to another format has no effect.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
-
Field Summary
-
Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_, noDefault
-
Fields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETEXTRAMS_JS
-
-
Constructor Summary
Constructors Constructor Description WDateEdit()Creates a new date edit.WDateEdit(WContainerWidget parentContainer)Creates a new date edit.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WDategetBottom()Returns the lower limit of the valid date range.WCalendargetCalendar()Returns the calendar widget.WDategetDate()Returns the date.WDateValidatorgetDateValidator()Returns the validator.java.lang.StringgetFormat()Returns the format.WDategetTop()Returns the upper limit of the valid range.protected java.lang.StringgetType()booleanisNativeControl()Returns whether a native HTML5 control is used.voidload()Loads content just before the widget is used.protected voidpropagateSetEnabled(boolean enabled)Propagates that a widget was enabled or disabled through children.voidrefresh()Refresh the widget.voidremove()Destructor.protected voidrender(java.util.EnumSet<RenderFlag> flags)Renders the widget.voidsetBottom(WDate bottom)Sets the lower limit of the valid date range.voidsetDate(WDate date)Sets the date.voidsetFormat(java.lang.String format)Sets the format used for representing the date.protected voidsetFromCalendar()Sets the value from the calendar to the line edit.protected voidsetFromLineEdit()Sets the value from the line edit to the calendar.voidsetHidden(boolean hidden, WAnimation animation)Hide/unhide the widget.voidsetNativeControl(boolean nativeControl)Changes whether a native HTML5 control is used.voidsetTop(WDate top)Sets the upper limit of the valid date range.protected voidvalidatorChanged()-
Methods inherited from class eu.webtoolkit.jwt.WLineEdit
boxBorder, boxPadding, getAutoCompleteToken, getCursorPosition, getDisplayText, getDomChanges, getEchoMode, getInputMask, getInputMode, getMaxLength, getSelectedText, getSelectionStart, getText, getTextSize, getValueText, hasSelectedText, isAutoComplete, setAutoComplete, setAutoComplete, setEchoMode, setFormData, setInputMask, setInputMask, setInputMask, setInputMask, setInputMode, setMaxLength, setSelection, setText, setTextSize, setValueText, textInput, validate
-
Methods inherited from class eu.webtoolkit.jwt.WFormWidget
changed, enableAjax, getLabel, getPlaceholderText, getRealValidator, getTabIndex, getValidator, hasValidatorChanged, isCanReceiveFocus, isReadOnly, setEnabled, setPlaceholderText, setReadOnly, setToolTip, setValidator, validated
-
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggable
-
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, createDomElement, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, hideToolTip, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, iterateChildren, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, removeScript, removeStyleClass, resize, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFlexBox, setFloatSide, setFocus, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setVerticalAlignment, showToolTip, showToolTipOnHover, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
-
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, applyThemeStyles, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, scheduleThemeStyleApply, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
-
Methods inherited from class eu.webtoolkit.jwt.WObject
getObjectName
-
-
-
-
Constructor Detail
-
WDateEdit
public WDateEdit(WContainerWidget parentContainer)
Creates a new date edit.
-
WDateEdit
public WDateEdit()
Creates a new date edit.
-
-
Method Detail
-
remove
public void remove()
Description copied from class:WFormWidgetDestructor.- Overrides:
removein classWFormWidget- See Also:
WWidget.removeWidget(WWidget widget)
-
setNativeControl
public void setNativeControl(boolean nativeControl)
Changes whether a native HTML5 control is used.When enabled the browser's native date input (<input type="date">) will be used, if available. This should provide a better experience on mobile browsers. This option is set to false by default.
Setting native control to true limits the format to "yyyy-MM-dd". Note that this is the format that the widget returns, not the format the user will see. This format is decided by the browser based on the user's locale.
There is no support for changing whether a native control is used after the widget is rendered.
- See Also:
isNativeControl()
-
isNativeControl
public boolean isNativeControl()
Returns whether a native HTML5 control is used.Taking into account the preference for a native control, configured using
setNativeControl(), this method returns whether a native control is actually being used.- See Also:
setNativeControl(boolean nativeControl)
-
setDate
public void setDate(WDate date)
Sets the date.Does nothing if the current date is
Null.- See Also:
getDate()
-
getDate
public WDate getDate()
Returns the date.Reads the current date.
Returns
nullif the date could not be parsed using the currentgetFormat().
- See Also:
setDate(WDate date),WLineEdit.getText()
-
getDateValidator
public WDateValidator getDateValidator()
Returns the validator.Most of the configuration of the date edit is stored in the validator.
Note: Using the validator to change the format while a native control is being used will break the native control. If a native control is used, do not call WDateValidator()::setFormat(), instead use
setFormat().- See Also:
WDateValidator(),setFormat(String format)
-
setFormat
public void setFormat(java.lang.String format)
Sets the format used for representing the date.This sets the format in the validator.
The default format is based on the current WLocale.
The format is set and limited to "yyyy-MM-dd" when using the native HTML5 control. Changing to another format has no effect.
-
getFormat
public java.lang.String getFormat()
Returns the format.- See Also:
setFormat(String format)
-
setBottom
public void setBottom(WDate bottom)
Sets the lower limit of the valid date range.This sets the lower limit of the valid date range in the validator.
- See Also:
WDateValidator.setBottom(WDate bottom)
-
getBottom
public WDate getBottom()
Returns the lower limit of the valid date range.- See Also:
setBottom(WDate bottom)
-
setTop
public void setTop(WDate top)
Sets the upper limit of the valid date range.This sets the upper limit of the valid date range in the validator.
- See Also:
WDateValidator.setTop(WDate top)
-
getTop
public WDate getTop()
Returns the upper limit of the valid range.- See Also:
setTop(WDate top)
-
getCalendar
public WCalendar getCalendar()
Returns the calendar widget.The calendar may be 0 (e.g. when using a native date entry widget).
-
setHidden
public void setHidden(boolean hidden, WAnimation animation)Hide/unhide the widget.- Overrides:
setHiddenin classWFormWidget
-
load
public void load()
Description copied from class:WWidgetLoads content just before the widget is used.This function is called when a widget is inserted in the widget hierarchy. Widgets that get inserted in the widget hierarchy will be rendered. Visible widgets are rendered immediately, and invisible widgets in the back-ground (or not for a plain HTML session). This method is called when the widget is directly or indirectly inserted into the widget tree.
The default implementation simply propagates the load signal to its children. You may want to override this method to delay loading of resource-intensive contents.
During the life-time of a widget, this method may be called multiple times, so you should make sure that you do a deferred initialization only once.
- Overrides:
loadin classWInteractWidget
-
refresh
public void refresh()
Description copied from class:WWidgetRefresh the widget.The refresh method is invoked when the locale is changed using
WApplication#setLocale()or when the user hit the refresh button.The widget must actualize its contents in response.
Note: This does not rerender the widget! Calling
refresh()usually does not have any effect (unless you've reimplementedrefresh()to attach to it an effect).- Overrides:
refreshin classWFormWidget
-
render
protected void render(java.util.EnumSet<RenderFlag> flags)
Description copied from class:WWidgetRenders the widget.This function renders the widget (or an update for the widget), after this has been scheduled using
scheduleRender().The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.
-
propagateSetEnabled
protected void propagateSetEnabled(boolean enabled)
Description copied from class:WWidgetPropagates that a widget was enabled or disabled through children.When enabling or disabling a widget, you usually also want to disable contained children. This method is called by
setDisabled()to propagate its state to all children.You may want to reimplement this method if they wish to render differently when a widget is disabled. The default implementation will propagate the signal to all children.
- Overrides:
propagateSetEnabledin classWFormWidget
-
validatorChanged
protected void validatorChanged()
- Overrides:
validatorChangedin classWFormWidget
-
setFromCalendar
protected void setFromCalendar()
Sets the value from the calendar to the line edit.
-
setFromLineEdit
protected void setFromLineEdit()
Sets the value from the line edit to the calendar.
-
-