Class TextItem
- All Implemented Interfaces:
Animatable<TextItem>,CanDrop<TextItem>,Clickable<TextItem>,SupportAppend<TextItem>,SupportHelpIcon<TextItem>,SupportPlaceholder<TextItem>,Draggable<TextItem>,Editable<TextItem>,Focusable<TextItem>,HandleHotKey<TextItem>,HandleKeyboardEvents<TextItem>,HandleMouseEvents<TextItem>,Scrollable<TextItem>,Touchable<TextItem>
Text Item
The component implements a text input field. This allows the user to input any text into the input field, that can be later used by the application. If the maximum text length is 255, then the field will be single line, if it is more than 255, it will be a larger input field (TextArea).
The component supports the use of masks. With the use of a mask, the user can be forced to use a certain text format, and ensure that the text is displayed in the correct format.
For more information about masks, see the setMask method description.
The TextItem component is a form item, that can be placed on a Form component, and the form handles it as well. The component can be used on its own,
but in that case, the handling of its events and values must be provided by the program code.
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,
Scrollable
TouchCancel,
TouchEnd,
TouchMove,
TouchStart,
Drop,
DragStart,
DragEnd
HotKey
- Since:
- 4.0
- Author:
- JBStrap
- See Also:
-
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, toolTipPositionFields inherited from interface com.jbstrap.ui.components.form.SupportAppend
LOG -
Constructor Summary
ConstructorsConstructorDescriptionTextItem(DataDescriptorColumn column) Creates a text input field form item, based on the specified DataDescriptor column.TextItem(DataDescriptorColumn column, String language) Creates a form item, based on the specified DataDescriptor column and using the specified language code.Creates a text input field with the specified name and label.Creates a text input field with the specified name, label and language. -
Method Summary
Modifier and TypeMethodDescriptionvoiddrawEditor(StringWriter writer) Draws the editor component.final TextItemforceTextArea(boolean forceTextArea) Sets if the text area is forced, regardless of the character length.final StringgetMask()Gets the mask of the text itemfinal intGets the maximum allowed length of the text itemsetDefaultValue(Object defaultValue) Sets the default value of the fieldfinal TextItemSets the specified input mask on the text input field.final TextItemsetMaxLength(int maxLength) Sets the maximum allowed length of the text item.Methods inherited from class com.jbstrap.ui.components.form.FormItem
_addComponent, _setReverseShow, _setState, addComponent, addRecalcOnChangeColumn, addRecalcOnChangeColumns, addRecalcOnChangeColumns, addValueChangeHandler, afterDraw, 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, getValueAsString, init, isAssignable, isAutoCalculate, isModified, isReadOnly, isRequired, isReverseShow, isShowLabel, isVisible, onFormItemValueChanged, onHotKeyEventHandler, onShow, redraw, removeParam, resetState, runAfterDrawOnAddon, runOnHideOnAddon, runOnShowOnAddon, setCalculateValue, setDataType, setDataType, setDescription, setEnabled, setFocus, setFormItemSize, setLabel, setLabelPosition, setLabelSize, setLabelSize, setMargin, setModified, setObjectValue, setOriginalObjectValue, setOriginalValue, setPadding, setParam, setParams, setReadOnly, setRequired, setShowLabel, setState, setTabIndex, setValue, 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.Scrollable
addScrollHandlerMethods inherited from interface com.jbstrap.ui.components.form.SupportAppend
append, append, append, prepend, prepend, prepend, removeAppend, removePrependMethods 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
-
TextItem
Creates a text input field with the specified name and label.- Parameters:
name- The name of the text input fieldlabel- The label of the field. Ifnull, the item won't have a label.- Throws:
NullPointerException- If the specified name isnull
-
TextItem
Creates a text input field with the specified name, label and language.- Parameters:
name- The name of the text input fieldlabel- The label of the field. Ifnull, the item 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 specified name isnull
-
TextItem
Creates a text input field form item, based on the specified DataDescriptor column.
The method creates and sets the text form item, based on the DataDescriptor column, specified in the parameters. The following parameters from the DataDescriptor column are used:
DataDescriptorColumn.getLength()- The maximum length of the column will be the maximum length of the text that can be inputted.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 anullvalue, the field will be marked as not mandatory. If it cannot have anullvalue, the field will be marked as mandatory.MetaParamName.MASK- The mask specified here will be used by the text input fieldMetaParamName.FORCE_TEXT_AREA- If this istrue, the text input will be forced to be a text area (multiple lines), regardless of the text length. Otherwise, the length will determine this. If the length is less or equal to 255 characters, the input field will be a single line box.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 text 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.
- Parameters:
column- The DataDescriptor column, that will be used as a basis for the form item.- Throws:
NullPointerException- If the column was specified asnull
-
TextItem
Creates a form item, based on the specified DataDescriptor column and using the specified language code.
The method creates and sets the form item, based on the DataDescriptor column, specified in the parameters. The following parameters from the DataDescriptor column are used:
DataDescriptorColumn.getLength()- The maximum length of the column will be the maximum length of the text that can be inputted.DataDesriptorColumn.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.MetaParamName.MASK- The mask specified here will be used by the text input fieldMetaParamName.FORCE_TEXT_AREA- If this istrue, the text input will be forced to be a text area (multiple lines), regardless of the text length. Otherwise, the length will determine this. If the length is less or equal to 255 characters, the input field will be a single line box.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 text 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.
- 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
-
setMask
Sets the specified input mask on the text input field.
By default, there is no mask applied. If a mask is specified, the user is forced to input text in the specified format. It also allows the text to be displayed in this specified format (mask).
Usable values:
- a - Letter characters (A-Z,a-z)
- 9 - Numeric characters (0-9)
- * - Alphanumeric characters (A-Z,a-z,0-9)
Examples
- Credit card number: "9999 9999 9999 9999"
- Telephone number: "(999) 999-9999"
- Date: "99/99/9999"
- Parameters:
mask- The mask to be applied. Ifnull, no mask will be applied.- Returns:
- Text item component
-
getMask
Gets the mask of the text item- Returns:
- The applied mask, or
nullif it has no mask
-
getMaxLength
public final int getMaxLength()Gets the maximum allowed length of the text item- Returns:
- The maximum length
-
setMaxLength
Sets the maximum allowed length of the text item. By default, the maximum text length is 255 characters.- Parameters:
maxLength- The maximum amount of characters- Returns:
- The Text item component
-
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<String,TextItem> - Parameters:
writer- The HTML string writer class instance; write here the HTML code for the input field
-
setDefaultValue
Sets the default value of the field- Specified by:
setDefaultValuein classFormItem<String,TextItem> - Parameters:
defaultValue- The default value of the field- Returns:
- Form item component
-
forceTextArea
Sets if the text area is forced, regardless of the character length.- Parameters:
forceTextArea- Iftrue, a larger text are will be used, even if the text is less than 255 characters long. Otherwise, if the maximum length is 255 or less, the input filed will use a single line only.- Returns:
- The Text item component
-