Class WDateTimeEdit
Wt/WDateTimeEdit.h
This editor is a line edit with support for a datetime entry. Users can fill in the datetime manually or rely on the popup. Using the icon of a calendar and clock.
In the popup a WTimePicker and WCalendar are shown to the user, allowing input in a
more structured manner.
Note: The WTimePicker does not support timezones, and consequentially this widget doesn't either. If supplied, it is ignored.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class WObject
WObject.FormData -
Field Summary
Fields inherited from class WInteractWidget
dragTouchEndSlot_, dragTouchSlot_, noDefaultFields inherited from class WWidget
WT_GETEXTRAMS_JS -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new DateTimeEdit.WDateTimeEdit(WContainerWidget parentContainer) Creates a new DateTimeEdit. -
Method Summary
Modifier and TypeMethodDescriptionvoidBrowses to a date.voidBrowses to the next month.voidBrowses to the same month in the next year.voidBrowses to the previous month.voidBrowses to the same month in the previous year.Returns the lower limit of the valid datetime range.intReturns the current month displayed.intReturns the current year displayed.Returns the datetime.Returns the datetime validator.Returns the datetime format.Returns the horizontal header format.intReturns the step size for the hours.intReturns the step size for the milliseconds.intReturns the step size for the minutes.intReturns the step size for the seconds.getTop()Returns the upper limit of the valid datetime range.protected StringgetType()booleanReturns whether a native HTML5 control is used, if supported.booleanReturns whether wraparound is enabled.voidload()Loads content just before the widget is used.voidrefresh()Refresh the widget.voidremove()Destructor.protected voidrender(EnumSet<RenderFlag> flags) Renders the widget.voidSets the lower limit of the valid datetime range.voidsetDateTime(WDate dateTime) Sets the date and time.voidsetFirstDayOfWeek(int dayOfWeek) Sets the first dat of the week.voidSets the format used for representing the datetime.protected voidSets the value from the line edit to the calenbdar and time picker.voidsetHidden(boolean hidden, WAnimation animation) Sets the hidden state of this widget.voidSets the horizontal header format.voidsetHourStep(int step) Sets the step size for the hours.voidsetMillisecondStep(int step) Sets the step size for the milliseconds.voidsetMinuteStep(int step) Sets the step size for the minutes.voidsetNativeControl(boolean nativeControl) Configures whether a native HTML5 control should be used.voidsetSecondStep(int step) Sets the step size for the seconds.voidSets the upper limit of the valid datetime range.voidsetWrapAroundEnabled(boolean rollover) Enables or disables wraparound for the time.protected voidMethods inherited from class 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, validateMethods inherited from class WFormWidget
changed, enableAjax, getLabel, getPlaceholderText, getRealValidator, getTabIndex, getValidator, hasValidatorChanged, isCanReceiveFocus, isReadOnly, propagateSetEnabled, setEnabled, setPlaceholderText, setReadOnly, setToolTip, setValidator, validatedMethods inherited from class 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, unsetDraggableMethods inherited from class WWebWidget
addStyleClass, anchorAt, becomePositionAnchor, beingDeleted, blurred, callJavaScriptMember, childrenChanged, createDomElement, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, formDataChanged, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionAnchor, getPositionAnchorName, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, hideToolTip, isDefaultNativeControl, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, iterateChildren, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, removeScript, removeStyleClass, resendFormData, resize, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDefaultNativeControl, setDeferredToolTip, setDisabled, setFlexBox, setFloatSide, setFocus, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionAnchor, setPositionAnchor, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setVerticalAlignment, showToolTip, showToolTipOnHover, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemovedMethods inherited from class WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, anchorAt, animateHide, animateShow, applyThemeStyles, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, isPositionAnchor, 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, trMethods inherited from class WObject
getObjectName
-
Constructor Details
-
WDateTimeEdit
Creates a new DateTimeEdit. -
WDateTimeEdit
public WDateTimeEdit()Creates a new DateTimeEdit.
-
-
Method Details
-
remove
public void remove()Description copied from class:WFormWidgetDestructor.- Overrides:
removein classWFormWidget- See Also:
-
setDateTime
Sets the date and time.Does nothing if the
dateTimeisnull.- See Also:
-
getDateTime
Returns the datetime.Reads the current datetime.
Returns
nullif the datetime could not be parsed using the currentgetFormat().- See Also:
-
getDateTimeValidator
Returns the datetime validator.Most of the configuration of the date time edit is stored in the validator.
- See Also:
-
setNativeControl
public void setNativeControl(boolean nativeControl) Configures whether a native HTML5 control should be used.When enabled, the browser's native datetime input (<input type="datetime-local">) will be used if available. This should provide a better experience on mobile browsers.
Setting native control to true limits the format to "yyyy-MM-ddThh:mm".
There is no support for changing the native control after the widget is rendered.
By default, this is set to the value of
WWebWidget.isDefaultNativeControl().- See Also:
-
isNativeControl
public boolean isNativeControl()Returns whether a native HTML5 control is used, if supported.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:
-
setFormat
Sets the format used for representing the datetime.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-ddThh:mm" when using the native HTML5 control. Changing to another format has no effect.
Note: The WTimePicker does not support timezones, and consequentially this widget doesn't either. If supplied, it is removed.
- See Also:
-
getFormat
-
setBottom
Sets the lower limit of the valid datetime range.This sets the lower limit of the valid datetime range in the datetime validator.
- See Also:
-
getBottom
-
setTop
Sets the upper limit of the valid datetime range.This sets the upper limit of the valid datetime range in the datetime validator.
- See Also:
-
getTop
-
browseToPreviousYear
public void browseToPreviousYear()Browses to the same month in the previous year.Displays the same month in the previous year. This does not affect the selection.
This will not affect a native widget.
- See Also:
-
browseToPreviousMonth
public void browseToPreviousMonth()Browses to the previous month.Displays the previous month. This does not affect the selection.
This will not affect a native widget.
- See Also:
-
browseToNextYear
public void browseToNextYear()Browses to the same month in the next year.Displays the same month in the next year. This does not change the current selection.
This will not affect a native widget.
- See Also:
-
browseToNextMonth
public void browseToNextMonth()Browses to the next month.Displays the next month. This does not affect the selection.
This will not affect a native widget.
- See Also:
-
browseTo
Browses to a date.Displays the month which contains the given date. This does not change the current selection.
This will not affect a native widget.
- See Also:
-
getCurrentYear
public int getCurrentYear()Returns the current year displayed.Returns the year that is currently displayed.
This will not work on a native widget.
- See Also:
-
getCurrentMonth
public int getCurrentMonth()Returns the current month displayed.Returns the month (1-12) that is currently displayed.
This will not work on a native widget.
- See Also:
-
setHorizontalHeaderFormat
Sets the horizontal header format.The default horizontal header format is
CalendarHeaderFormat.ShortDayNamesThis will have no effect on a native widget.
-
getHorizontalHeaderFormat
Returns the horizontal header format.This will not work on a native widget.
-
setFirstDayOfWeek
public void setFirstDayOfWeek(int dayOfWeek) Sets the first dat of the week.Possible values are 1 to 7. The default value is 1 ("Monday").
This will have no effect on a native widget.
- See Also:
-
setHourStep
public void setHourStep(int step) Sets the step size for the hours.This only impacts the time sections of the widget.
This will have no effect on a native widget.
- See Also:
-
getHourStep
public int getHourStep()Returns the step size for the hours.This will have no effect on a native widget.
- See Also:
-
setMinuteStep
public void setMinuteStep(int step) Sets the step size for the minutes.This only impacts the time sections of the widget.
This will have no effect on a native widget.
- See Also:
-
getMinuteStep
public int getMinuteStep()Returns the step size for the minutes.This will have no effect on a native widget.
- See Also:
-
setSecondStep
public void setSecondStep(int step) Sets the step size for the seconds.This only impacts the time sections of the widget.
This will have no effect on a native widget.
- See Also:
-
getSecondStep
public int getSecondStep()Returns the step size for the seconds.This will have no effect on a native widget. @see WDateTimeEdit#setSecondStep(int step)
- See Also:
-
setMillisecondStep
public void setMillisecondStep(int step) Sets the step size for the milliseconds.This only impacts the time sections of the widget.
This will have no effect on a native widget.
- See Also:
-
getMillisecondStep
public int getMillisecondStep()Returns the step size for the milliseconds.This will have no effect on a native widget.
- See Also:
-
setWrapAroundEnabled
public void setWrapAroundEnabled(boolean rollover) Enables or disables wraparound for the time.Wraparound is enabled by default. This will ensure that the widgets that selects the units of time will wrap around to their lowest possible value when exceeding their maximum value.
This will have no effect on a native widget.
- See Also:
-
isWrapAroundEnabled
public boolean isWrapAroundEnabled()Returns whether wraparound is enabled.This will have no effect on a native widget.
- See Also:
-
setHidden
Description copied from class:WFormWidgetSets the hidden state of this widget.If the widget has a label, it is hidden and shown together with this 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
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.
-
setFromLineEdit
protected void setFromLineEdit()Sets the value from the line edit to the calenbdar and time picker. -
validatorChanged
protected void validatorChanged()- Overrides:
validatorChangedin classWFormWidget
-
getType
-