Class DatePicker
- All Implemented Interfaces:
Animatable<DatePicker>,CanDrop<DatePicker>,Clickable<DatePicker>,SupportAppend<DatePicker>,SupportHelpIcon<DatePicker>,SupportPlaceholder<DatePicker>,Draggable<DatePicker>,Editable<DatePicker>,Focusable<DatePicker>,HandleHotKey<DatePicker>,HandleKeyboardEvents<DatePicker>,HandleMouseEvents<DatePicker>,Touchable<DatePicker>
Date picker form item>
The date picker form element is for inputting a date and/or time. With this component, the user can input a date and/or time, using a dropdown calendar. This ensures that the format of the date will be correct.
Supported events:
AnimationStart
AnimationEnd,
Focus
FocusOut
FocusIn
LosesFocus
copy
cut
EnterPressed
input
paste
Click,
DoubleClick,
MouseDown,
MouseDown,
MouseLeave,
MouseMove,
MouseOver,
MouseOut,
MouseUp,
Wheel,
KeyPress,
KeyUp,
KeyDown,
TouchCancel,
TouchEnd,
TouchMove,
TouchStart,
Drop,
DragStart,
DragEnd
HotKey
- Since:
- 4.0
- Author:
- JBStrap
-
Field Summary
Fields inherited from class com.jbstrap.ui.components.form.FormItem
appends, clearButton, column, defaultState, defaultValue, description, formItemSize, helpIcon, label, labelPosition, labelSizes, modified, originalValue, params, prepends, required, showLabel, state, tabIndex, value, visibleFields inherited from class com.jbstrap.ui.Component
animation, attributes, backgroundColor, borderColor, color, defaultHotKeyHandler, handlers, hotKeys, styleClasses, textAlign, toolTip, toolTipPosition -
Constructor Summary
ConstructorsConstructorDescriptionDatePicker(DataDescriptorColumn column) Createts a date picker item, based on the specified DataDescriptor column.DatePicker(DataDescriptorColumn column, String language) Createts a date picker item, based on the specified DataDescriptor column and using the specified language code.DatePicker(String name, String label) Creates a date picker input field with the specified name and label.DatePicker(String name, String label, String language) Creates a date picker item, with the specified name and label, and the specified language code.DatePicker(String name, String label, String language, String dateFormat) Creates a date picker item, with the specified name, label, date format and the specified language code. -
Method Summary
Modifier and TypeMethodDescriptionvoidThe operations to be executed after the drawing of the componentAppends a component after the input field.Displays an icon after the input field.Appends a text after the input field.voiddrawEditor(StringWriter writer) Draws the editor component.Gets the component’s date format.Gets the side of the input field where the dropdown calendar is displayed.final DateGets the maximum datefinal DateGets the minimum dateGets the form item’s current value as String.voidinit()The component initialization method.booleanChecks if the user is allowed to select a year or month by clicking on the dropdown menu.Appends a component before the input field.Appends an icon before the input field.Appends a text before the input field.removeAppend(int index) Removes a component instance from after the input field.removePrepend(int index) Removes an object from before the input field using its index.setDateFormat(String dateFormat) Sets the component’s date format.setDefaultValue(Object defaultValue) Sets the default value of the date picker, based on the specified object.
The value is interpreted, following these rules: Ifnull, the value will benullIf the specified value is aDatetype, or extends from it, the object value will be the specified value If notnullor notDatetype, then the specified value's text format will be converted by the component to fit the date format.setDropDownPosition(DropDownPosition position) Sets on which side of the input field the dropdown calendar is displayed.setEnabled(boolean enabled) Sets the date picker to be enabled.final DatePickersetMaximumDate(Date maxDate) Sets the maximum date.final DatePickersetMinimumDate(Date minDate) Sets the minimum date.setObjectValue(Object value) Sets the form item’s current value using the object in the parameter.setOriginalObjectValue(Object value) Sets the form item’s original value using the object in the parameter.setOriginalValue(Date originalValue) Sets the original value of the date picker.setReadOnly(boolean readOnly) Sets the date picker to read-only mode.setShowDropdowns(boolean show) Sets if year and month selection is done by clicking on a dropdown menu.Sets the date picker's value.Methods inherited from class com.jbstrap.ui.components.form.FormItem
_addComponent, _setReverseShow, _setState, addComponent, addRecalcOnChangeColumn, addRecalcOnChangeColumns, addRecalcOnChangeColumns, addValueChangeHandler, clearValue, convertValueToJavaScript, convertValueToJavaScript, drawComponent, enableClearButton, eraseValue, getCalculateValue, getColumn, getComponents, getDataType, getDefaultState, getDescription, getFormItemSize, getLabel, getLabelPosition, getLabelSize, getLabelSize, getName, getOriginalValue, getParam, getParamAsBoolean, getParamAsDate, getParamAsDate, getParamAsDouble, getParamAsInteger, getParamAsLong, getParamAsNumber, getParamAsString, getRecalcOnChangeColumnsList, getState, getTabIndex, getValue, getValueAsBoolean, getValueAsDate, getValueAsDouble, getValueAsFloat, getValueAsInteger, getValueAsLong, isAssignable, isAutoCalculate, isModified, isReadOnly, isRequired, isReverseShow, isShowLabel, isVisible, onFormItemValueChanged, onHotKeyEventHandler, onShow, redraw, removeParam, resetState, runAfterDrawOnAddon, runOnHideOnAddon, runOnShowOnAddon, setCalculateValue, setDataType, setDataType, setDescription, setFocus, setFormItemSize, setLabel, setLabelPosition, setLabelSize, setLabelSize, setMargin, setModified, setPadding, setParam, setParams, setRequired, setShowLabel, setState, setTabIndex, setVisible, triggerFormChange, writeHTMLMethods inherited from class com.jbstrap.ui.Component
_hide, _setAttribute, addAllowedRole, addComponent, addComponents, addDeniedRole, addHandler, addStyle, addStyleClass, addStyleClasses, clearfix, closeTag, combinateAccess, containsStyle, containsStyleClass, draw, drawSubComponents, error, flattendComponentTree, getAccess, getAccessMode, getAllowedRoles, getAttribute, getAttributes, getBackgroundColor, getBorderColor, getClient, getComponentById, getComponents, getComponentsByClass, getData, getDeniedRoles, getHandlers, getId, getLanguageCode, getParent, getParent, getRegisteredEvents, getStyle, getStyleClasses, getTextAlign, getTextColor, getToolTip, getToolTipPosition, getTypeName, getUI, insertComponentAfter, insertComponentBefore, isAccess, isDrawn, isEnabled, isEventBubbling, onHide, openTag, removeAllComponents, removeAllowedRole, removeAllStyleClasses, removeAttribute, removeComponent, removeComponent, removeComponents, removeDeniedRole, removeHandler, removeStyle, removeStyle, removeStyleClass, removeStyleClasses, replaceComponent, replaceStyleClass, runAfterDraw, runJavaScript, runJavaScript, runJavaScript, runOnHide, runOnShow, say, setAttribute, setBackgroundColor, setBorder, setBorderColor, setData, setDisplayType, setEventBubbling, setFlex, setFloating, setHeight100, setHeight25, setHeight50, setHeight75, setHeightAuto, setLanguage, setName, setOverflow, setParent, setScrollable, setSelectionType, setShadow, setStyle, setTextAlign, setTextColor, setToolTip, setToolTipPosition, setWidth100, setWidth25, setWidth50, setWidth75, setWidthAuto, showNotification, showNotification, showProcessIndicator, toggleStyleClassMethods inherited from class com.jbstrap.core.messagebus.MessageBus
closeMessageBus, messageBusOpened, openMessageBus, renewSubscription, sendMessageToMessageBus, subscribeMessageBus, unsubscribeAllListeners, unsubscribeMessageBusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.jbstrap.ui.Animatable
addAnimationEndHandler, addAnimationStartHandler, getAnimation, removeAnimation, setAnimationMethods inherited from interface com.jbstrap.ui.CanDrop
addDropEventHandlerMethods inherited from interface com.jbstrap.ui.Clickable
addClickHandler, addDoubleClickHandlerMethods inherited from interface com.jbstrap.ui.Draggable
addDragEndEventHandler, addDragStartEventHandler, setDraggableMethods inherited from interface com.jbstrap.ui.Editable
addCopyHandler, addCutHandler, addEnterPressedHandler, addInputHandler, addPasteHandlerMethods inherited from interface com.jbstrap.ui.Focusable
addFocusHandler, addFocusInHandler, addFocusOutHandler, addLosesFocusHandler, setFocusMethods inherited from interface com.jbstrap.ui.HandleHotKey
addHotKey, addHotKey, removeHotKey, removeHotKeysMethods inherited from interface com.jbstrap.ui.HandleKeyboardEvents
addKeyDownHandler, addKeyPressHandler, addKeyUpHandlerMethods inherited from interface com.jbstrap.ui.HandleMouseEvents
addMouseDownHandler, addMouseEnterHandler, addMouseLeaveHandler, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandlerMethods inherited from interface com.jbstrap.ui.components.form.SupportHelpIcon
getHelpIcon, getHelpText, setHelpIcon, setHelpTextMethods inherited from interface com.jbstrap.ui.components.form.SupportPlaceholder
getPlaceholder, setPlaceholderMethods inherited from interface com.jbstrap.ui.Touchable
addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler
-
Constructor Details
-
DatePicker
Creates a date picker input field with the specified name and label.- Parameters:
name- The name of the itemlabel- The label of the item. Ifnull, it won't have a label.- Throws:
NullPointerException- If the name isnull
-
DatePicker
Creates a date picker item, with the specified name and label, and the specified language code.- Parameters:
name- The name of the itemlabel- The label of the item. Ifnull, it won't have a label.language- The language code, that the form item will use. If not specified, ornull, the framework will use the default language. The default language can be set with theJBStrapParamType.DEFAULT_LANGUAGEJBStrap parameter.- Throws:
NullPointerException- If the name isnull
-
DatePicker
Creates a date picker item, with the specified name, label, date format and the specified language code.- Parameters:
name- The name of the itemlabel- The label of the item. Ifnull, it won't have a label.language- The language code, that the form item will use. If not specified, ornull, the framework will use the default language. The default language can be set with theJBStrapParamType.DEFAULT_LANGUAGEJBStrap parameter.dateFormat- The date format to be used when displaying a date. If not specified, the default format will be used, which can be specified using theJBStrapParamType.DATE_FORMATJBStrap parameter.- Throws:
NullPointerException- If the name isnull
-
DatePicker
Createts a date picker item, based on the specified DataDescriptor column.
The method creates and sets the date picker item, based on the DataDescriptor column, specified in the parameters. The following parameters from the DataDescriptor column are used:
DataDecriptorColumn.getTitle- The title set in the DataDescriptor column will be used by the input field as its label.DataDescriptorColumn.isNullable()- If the field can anullvalue, the field will be marked as not mandatory. If it cannot have anullvalue, the field will be marked as mandatory.MetaParamName.DATE_FORMAT- The date format to be used when displaying a date. If not specified, the default format will be used, which can be specified using theJBStrapParamType.DATE_FORMATandJBStrapParamType.DATETIME_FORMATJBStrap parameters.MetaParamName.PLACEHOLDER- This text will be used as a placeholder.MetaParamName.SIZE- The value specified here defines the size of the input field. (Applicable values: SMALL, MEDIUM, LARGE)MetaParamName.STATE- The value specified here defines the state of the input field. (Applicable values: DEFAULT, ERROR, WARNING, SUCCESS, INFO)MetaParamName.DEFAULT_VALUE- The value specified here defines the field's default value. The value must have the type of field, in this case, it must be a boolean value.MetaParamName.READ_ONLY- Iftrue, the field will be read only. Otherwise, the field can have its contents modified by the user.MetaParamName.ENABLED- Iffalse, the field will be disabled (it will be created in an unusable state.) Otherwise, the field will be enabled when created.MetaParamName.HELP- If the parameter is specified, an icon will be displayed next to the field. If the user moves over the icon, the text specified here will be displayed, as a help text.MetaParamName.HELP_ICON- If the icon name is specified (from theIconenum), then this icon will replace the default "?" icon.MetaParamName.DESCRIPTION- The text specified here will appear below the field, in a smaller, italic font.MetaParamName.TAB_INDEX- The value specified here determines the order of the input focus (when the user presses the Tab key). The order goes in ascending order. If not specified, the component will use the order value from the DataDescriptor. If that not specified either, the order in which it was placed in the DataDescriptor will be used.MetaParamName.SHOW_DROPDOWN- Ezzel a paraméterrel lehet beállítani, hogy a felhasználónak van-e lehetősége az évek és a hónapok közöt lenyíló menüből választani. Alapértelmezés szerint a felhasználónak van lehetősége lenyíló menüből évet és hónapot választani. Ha megadjuk a paramétert, és a paraméter értéke false, akkor a felhasználónak nem lesz lehetősége íly módon választani, csak a naptár felett található előre és hátra lapozással fog tudni váltani a hónapok között.
- Parameters:
column- The DataDescriptor column, that will be used as a basis for the form item.- Throws:
NullPointerException- If the column was specified asnull
-
DatePicker
Createts a date picker item, based on the specified DataDescriptor column and using the specified language code.
The method creates and sets the date picker item, based on the DataDescriptor column, specified in the parameters. The following parameters from the DataDescriptor column are used:
DataDescriptorColumn.getTitle- The title set in the DataDescriptor column will be used by the input field as its label.DataDescriptorColumn.isNullable()- If the field can have anullvalue, the field will be marked as not mandatory. If it cannot have anullvalue, the field will be marked as mandatory.MetaParamName.DATE_FORMAT- The date format to be used when displaying a date. If not specified, the default format will be used, which can be specified using theJBStrapParamType.DATE_FORMATandJBStrapParamType.DATETIME_FORMATJBStrap parameters.MetaParamName.PLACEHOLDER- This text will be used as a placeholder.MetaParamName.SIZE- The value specified here defines the size of the input field. (Applicable values: SMALL, MEDIUM, LARGE)MetaParamName.STATE- The value specified here defines the state of the input field. (Applicable values: DEFAULT, ERROR, WARNING, SUCCESS, INFO)MetaParamName.DEFAULT_VALUE- The value specified here defines the field's default value. The value must have the type of field, in this case, it must be a boolean value.MetaParamName.READ_ONLY- Iftrue, the field will be read only. Otherwise, the field can have its contents modified by the user.MetaParamName.ENABLED- Iffalse, the field will be disabled (it will be created in an unusable state.) Otherwise, the field will be enabled when created.MetaParamName.HELP- If the parameter is specified, an icon will be displayed next to the field. If the user moves over the icon, the text specified here will be displayed, as a help text.MetaParamName.HELP_ICON- If the icon name is specified (from theIconenum), then this icon will replace the default "?" icon.MetaParamName.DESCRIPTION- The text specified here will appear below the field, in a smaller, italic font.MetaParamName.TAB_INDEX- The value specified here determines the order of the input focus (when the user presses the Tab key). The order goes in ascending order. If not specified, the component will use the order value from the DataDescriptor. If that not specified either, the order in which it was placed in the DataDescriptor will be used.MetaParamName.SHOW_DROPDOWN- Use this parameter to set if the user is allowed to select from the dropdown menu. By default, the user is allowed to select a year and a month from the dropdown menu. If the parameter is specified as false, the user is not allowed to select from the dropdown menu. Month selection is only possible by clicking on the next and previous buttons above the calendar.
- Parameters:
column- The DataDescriptor column, that will be used as a basis for the form item.language- The language code, that the form item will use. If not specified, ornull, the framework will use the default language. The default language can be set with theJBStrapParamType.DEFAULT_LANGUAGEJBStrap parameter.- Throws:
NullPointerException- If the column was specified asnull
-
-
Method Details
-
init
Description copied from class:ComponentThe component initialization method.Empty method, only needs to be overwritten when making a custom component, that needs to call an initializing JavaScript on the client side. The method is called by the framework after the component is drawn, but before the afterDraw() method. The use of this method during application development is not allowed. This method is meant for inner use only.
- Overrides:
initin classFormItem<Date,DatePicker> - Throws:
JavaScriptLoadError- If there was a JavaScript error during the initialization.
-
drawEditor
Description copied from class:FormItemDraws the editor component.
You do not need to use this method during development, but all components extending the form item must implement it. Use the method to generate the input field’s HTML code. This code is then inserted into the corresponding DOM code when drawing the form item.
- Specified by:
drawEditorin classFormItem<Date,DatePicker> - Parameters:
writer- The HTML string writer class instance; write here the HTML code for the input field
-
setDateFormat
Sets the component’s date format.- Parameters:
dateFormat- The date format used by the component Ifnullis set, the framework’s default date format is used. The framework’s default date format can be set using the JBStrap parameterJBStrapParamType.DATE_FORMAT.- Returns:
- Date picker component
-
getDateFormat
Gets the component’s date format.- Returns:
- The date format used by the component
-
setMinimumDate
Sets the minimum date. If specified, the user cannot pick an earlier date. If the user manually inputs a date earlier than the specified minimum date, the date will be automatically modified to the minimum date.- Parameters:
minDate- The minimum date- Returns:
- The date picker component
-
getMinimumDate
Gets the minimum date- Returns:
- The minimum date or
null, if no minimum date was specified
-
setMaximumDate
Sets the maximum date. If specified, the user cannot pick a later date. If the user manually inputs a date later than the specified maximum date, the date will be automatically modified to the maximum date.- Parameters:
maxDate- The maximum date- Returns:
- The date picker component
-
getMaximumDate
Gets the maximum date- Returns:
- The maximum date or
null, if no maximum date was specified
-
setDropDownPosition
Sets on which side of the input field the dropdown calendar is displayed. By default, the dropdown calendar appears on the left of the input field.- Parameters:
position- The position where the dropdown calendar is displayed Ifnullis set, the dropdown calendar is displayed on the left side of the input field.- Returns:
- Date picker component
-
getDropDownPosition
Gets the side of the input field where the dropdown calendar is displayed.- Returns:
- The position where the dropdown calendar is displayed
-
setShowDropdowns
Sets if year and month selection is done by clicking on a dropdown menu. By default, year and month selection is done by clicking on a dropdown menu.- Parameters:
show- Iftrueis set, year and month selection is done by clicking on a dropdown menu. Iffalseis set, the user is only allowed to increase or decrease months.- Returns:
- Date picker component
-
isShowDropdowns
public boolean isShowDropdowns()Checks if the user is allowed to select a year or month by clicking on the dropdown menu.- Returns:
- If
true, the user is allowed to select a year or a month from the dropdown menu. Otherwise, the user is only allowed to step back and forward between months.
-
afterDraw
public void afterDraw()Description copied from class:ComponentThe operations to be executed after the drawing of the componentBy default, this is an empty method. It has to be overwritten on a component or page if additional operations have to be executed after the drawing process. One such operation is data retrieval, which shouldn't run in constructors so that the user could see results of an operation or navigation process.
- Overrides:
afterDrawin classFormItem<Date,DatePicker>
-
setValue
Sets the date picker's value.- Overrides:
setValuein classFormItem<Date,DatePicker> - Parameters:
value- The date picker value- Returns:
- The date picker component
-
setOriginalValue
Sets the original value of the date picker.- Overrides:
setOriginalValuein classFormItem<Date,DatePicker> - Parameters:
originalValue- The original value- Returns:
- The date picker component
-
setObjectValue
Description copied from class:FormItemSets the form item’s current value using the object in the parameter.- Overrides:
setObjectValuein classFormItem<Date,DatePicker> - Parameters:
value- The date picker actual value- Returns:
- The date picker component
-
setOriginalObjectValue
Description copied from class:FormItemSets the form item’s original value using the object in the parameter.- Overrides:
setOriginalObjectValuein classFormItem<Date,DatePicker> - Parameters:
value- The date picker original value- Returns:
- The date picker component
-
setDefaultValue
Sets the default value of the date picker, based on the specified object.
The value is interpreted, following these rules:- If
null, the value will benull - If the specified value is a
Datetype, or extends from it, the object value will be the specified value - If not
nullor notDatetype, then the specified value's text format will be converted by the component to fit the date format. If successful, the value will be set and formatted, if not, an exception will be thrown
- Specified by:
setDefaultValuein classFormItem<Date,DatePicker> - Parameters:
defaultValue- The default value of the date picker- Returns:
- The date picker component
- Throws:
IllegalArgumentException- If the specified object couldn't be interpreted as a Date
- If
-
getValueAsString
Gets the form item’s current value as String.- Overrides:
getValueAsStringin classFormItem<Date,DatePicker> - Returns:
- Current value of the form item in String format
-
setReadOnly
Sets the date picker to read-only mode. By default, the date picker is displayed as writable and the user can freely modify the form item value. If the component is set to read-only mode, the user is unable to modify the date picker value.- Overrides:
setReadOnlyin classFormItem<Date,DatePicker> - Parameters:
readOnly- Iftrueis set, the date picker is switched to read-only mode and the user is unable to modify the value. Iffalseis set, the date picker is switched to writable mode and the user is able to modify form item value.- Returns:
- Date picker component
-
setEnabled
Sets the date picker to be enabled. Defaults totrue- Overrides:
setEnabledin classFormItem<Date,DatePicker> - Parameters:
enabled-true, the component is enabled, otherwise it's disabled- Returns:
- Date picker component
-
prepend
Description copied from interface:SupportAppendAppends a component before the input field.- Specified by:
prependin interfaceSupportAppend<DatePicker>- Parameters:
component- Component instance Ifnullor is specified, nothing is displayed before the input field.- Returns:
- Form item component
-
prepend
Description copied from interface:SupportAppendAppends an icon before the input field.- Specified by:
prependin interfaceSupportAppend<DatePicker>- Parameters:
icon- Icon Ifnullis specified, nothing is displayed before the input field. Available icons are listed in the enumIcon.- Returns:
- Form item component
-
prepend
Description copied from interface:SupportAppendAppends a text before the input field.- Specified by:
prependin interfaceSupportAppend<DatePicker>- Parameters:
text- Appended text Ifnullor an empty string is specified, nothing is displayed before the input field- Returns:
- Form item component
-
removePrepend
Description copied from interface:SupportAppendRemoves an object from before the input field using its index. The first item has the index 0.- Specified by:
removePrependin interfaceSupportAppend<DatePicker>- Parameters:
index- Index If a nonexistent index is specified, removal is not successful.- Returns:
- Form item component
-
append
Description copied from interface:SupportAppendAppends a component after the input field.- Specified by:
appendin interfaceSupportAppend<DatePicker>- Parameters:
component- Component instance Ifnullor is specified, nothing is displayed after the input field.- Returns:
- Form item component
-
append
Description copied from interface:SupportAppendDisplays an icon after the input field.- Specified by:
appendin interfaceSupportAppend<DatePicker>- Parameters:
icon- Icon Ifnullor is specified, nothing is displayed after the input field. Available icons are listed in the enumIcon.- Returns:
- Form item component
-
append
Description copied from interface:SupportAppendAppends a text after the input field.- Specified by:
appendin interfaceSupportAppend<DatePicker>- Parameters:
text- Text Ifnullor an empty string is specified, nothing is displayed after the input field.- Returns:
- Form item component
-
removeAppend
Description copied from interface:SupportAppendRemoves a component instance from after the input field. The first item’s index is 0.- Specified by:
removeAppendin interfaceSupportAppend<DatePicker>- Parameters:
index- Index If a nonexistent index is specified, removal is not successful.- Returns:
- Form item component
-