Class CheckboxItem
- All Implemented Interfaces:
Animatable<CheckboxItem>
,CanDrop<CheckboxItem>
,Clickable<CheckboxItem>
,BooleanValueFormItem
,SupportHelpIcon<CheckboxItem>
,Draggable<CheckboxItem>
,Focusable<CheckboxItem>
,HandleMouseEvents<CheckboxItem>
,Touchable<CheckboxItem>
Checkbox item
The checkbox item is used to input a logic value. The user can check the box that is displayed, which is interpreted as a true
value,
if the box is not checked, it is considered a false
value. The field does not support the use of the null
value.
The Checkbox 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
Click
,
DoubleClick
,
MouseDown
,
MouseDown
,
MouseLeave
,
MouseMove
,
MouseOver
,
MouseOut
,
MouseUp
,
Wheel
,
TouchCancel
,
TouchEnd
,
TouchMove
,
TouchStart
,
Drop
,
DragStart
,
DragEnd
- 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, visible
Fields inherited from class com.jbstrap.ui.Component
animation, attributes, backgroundColor, borderColor, color, defaultHotKeyHandler, handlers, hotKeys, styleClasses, textAlign, toolTip, toolTipPosition
-
Constructor Summary
ConstructorDescriptionCheckboxItem
(DataDescriptorColumn column) Createts a checkbox item, based on the specified DataDescriptor column.CheckboxItem
(DataDescriptorColumn column, String language) Creates a checkbox item, based on the specified DataDescriptor column and using the specified language code.CheckboxItem
(String name, String label) Creates a checkbox item, with the specified name and label.CheckboxItem
(String name, String label, StyleElement... styles) Creates a checkbox item, with the specified name, label and style.CheckboxItem
(String name, String label, String language) Creates a checkbox item, with the specified name and label, and the specified language code.CheckboxItem
(String name, String label, String language, StyleElement... styles) Creates a checkbox item, with the specified name, label and style, with the specified language code. -
Method Summary
Modifier and TypeMethodDescriptionvoid
drawEditor
(StringWriter writer) Draws the editor component.final boolean
Determines if the box is checked.final CheckboxItem
setCheckboxShape
(CheckboxShape checkboxShape) Sets the checkbox shape.final CheckboxItem
setCheckboxType
(CheckboxType checkboxType) Sets the checkbox type (color).setDefaultValue
(Object defaultValue) Sets the default value of the checkbox, following the specified object.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
(Boolean originalValue) Sets the checkbox original value, and actual value at the same time.final CheckboxItem
setReadOnly
(boolean readOnly) Sets if the checkbox is read-only.setReverseShow
(boolean reverse) setState
(FormItemState formItemState) Sets the checkbox state.Sets the checkbox value.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, setPadding, setParam, setParams, setRequired, setShowLabel, setTabIndex, setVisible, triggerFormChange, writeHTML
Methods 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, toggleStyleClass
Methods inherited from class com.jbstrap.core.messagebus.MessageBus
closeMessageBus, messageBusOpened, openMessageBus, renewSubscription, sendMessageToMessageBus, subscribeMessageBus, unsubscribeAllListeners, unsubscribeMessageBus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jbstrap.ui.Animatable
addAnimationEndHandler, addAnimationStartHandler, getAnimation, removeAnimation, setAnimation
Methods inherited from interface com.jbstrap.ui.CanDrop
addDropEventHandler
Methods inherited from interface com.jbstrap.ui.Clickable
addClickHandler, addDoubleClickHandler
Methods inherited from interface com.jbstrap.ui.Draggable
addDragEndEventHandler, addDragStartEventHandler, setDraggable
Methods inherited from interface com.jbstrap.ui.Focusable
addFocusHandler, addFocusInHandler, addFocusOutHandler, addLosesFocusHandler
Methods inherited from interface com.jbstrap.ui.HandleMouseEvents
addMouseDownHandler, addMouseEnterHandler, addMouseLeaveHandler, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler
Methods inherited from interface com.jbstrap.ui.components.form.SupportHelpIcon
getHelpIcon, getHelpText, setHelpIcon, setHelpText
Methods inherited from interface com.jbstrap.ui.Touchable
addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler
-
Constructor Details
-
CheckboxItem
Creates a checkbox item, 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
-
CheckboxItem
Creates a checkbox 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_LANGUAGE
JBStrap parameter.- Throws:
NullPointerException
- If the name isnull
-
CheckboxItem
Creates a checkbox item, with the specified name, label and style.- Parameters:
name
- The name of the itemlabel
- The label of the item. Ifnull
, it won't have a label.styles
- The checkbox style. Usable values:CheckboxShape
enum- Throws:
NullPointerException
- If the name isnull
-
CheckboxItem
Creates a checkbox item, with the specified name, label and style, with 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_LANGUAGE
JBStrap parameter.styles
- The checkbox style. Usable values:CheckboxShape
enum- Throws:
NullPointerException
- If the name isnull
-
CheckboxItem
Createts a checkbox item, based on the specified DataDescriptor column.
The method creates and sets the checkbox 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 anull
value, the field will be marked as not mandatory. If it cannot have anull
value, the field will be marked as mandatory.MetaParamName.TYPE
- The value specifies the checkbox color. (Usable values: DEFAULT, PRIMARY, SUCCESS, INFO, WARNING, DANGER)MetaParamName.SHAPE
- The value specifies the checkbox shape. (Usable values: DEFAULT, CIRCLE)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 theIcon
enum), 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
-
CheckboxItem
Creates a checkbox item, based on the specified DataDescriptor column and using the specified language code.
The method creates and sets the checkbox 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 anull
value, the field will be marked as not mandatory. If it cannot have anull
value, the field will be marked as mandatory.MetaParamName.TYPE
- The value specifies the checkbox color. (Usable values: DEFAULT, PRIMARY, SUCCESS, INFO, WARNING, DANGER)MetaParamName.SHAPE
- The value specifies the checkbox shape. (Usable values: DEFAULT, CIRCLE)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 theIcon
enum), 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_LANGUAGE
JBStrap parameter.- Throws:
NullPointerException
- If the column was specified asnull
-
-
Method Details
-
setCheckboxType
Sets the checkbox type (color). Defaults to DEFAULT- Parameters:
checkboxType
- The checkbox type. Usable values:CheckboxType
enum- Returns:
- The checkbox item component
-
setCheckboxShape
Sets the checkbox shape. The default shape is a rectangular checkbox (DEFAULT).- Parameters:
checkboxShape
- The checkbox shape. Usable values:CheckboxShape
enum- Returns:
- The checkbox item component
-
isChecked
public final boolean isChecked()Determines if the box is checked.- Returns:
- If
true
, it is checked, otherwisefalse
-
setState
Sets the checkbox state. The default state is DEFAULT- Overrides:
setState
in classFormItem<Boolean,
CheckboxItem> - Parameters:
formItemState
- The checkbox state. Usable values:FormItemState
enum- Returns:
- The checkbox item component
-
drawEditor
Description copied from class:FormItem
Draws 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:
drawEditor
in classFormItem<Boolean,
CheckboxItem> - Parameters:
writer
- The HTML string writer class instance; write here the HTML code for the input field
-
setValue
Sets the checkbox value. Ifnull
, the checkbox will have afalse
value.- Overrides:
setValue
in classFormItem<Boolean,
CheckboxItem> - Parameters:
value
- Current value of the checkbox item- Returns:
- The checkbox item component
-
setOriginalValue
Sets the checkbox original value, and actual value at the same time. If the user modifies the checkbox value, the original value won't change. This means that it can be determined if the user has modified the checkbox value.- Overrides:
setOriginalValue
in classFormItem<Boolean,
CheckboxItem> - Parameters:
originalValue
- The value that will be the original and actual value- Returns:
- The checkbox item component
-
setObjectValue
Description copied from class:FormItem
Sets the form item’s current value using the object in the parameter.- Overrides:
setObjectValue
in classFormItem<Boolean,
CheckboxItem> - Parameters:
value
- The checkbox actual value- Returns:
- The checkbox item component
-
setOriginalObjectValue
Description copied from class:FormItem
Sets the form item’s original value using the object in the parameter.- Overrides:
setOriginalObjectValue
in classFormItem<Boolean,
CheckboxItem> - Parameters:
value
- The value that will be the original and actual value- Returns:
- The checkbox item component
-
setDefaultValue
Sets the default value of the checkbox, following the specified object. The value is interpreted, following these rules:- If
null
, thefalse
value will be set. - If the specified value is from
Boolean
class, then that value will be set. - In other cases, the framework will try to interpret the value as a logic value, and set the switch value accordingly. In this case,
a
true
value is set if the specified value is one of the following: 1, 1L, "1", "Y", "YES", "TRUE", "T", "ON". This check is not case-sensitive.
- Specified by:
setDefaultValue
in classFormItem<Boolean,
CheckboxItem> - Parameters:
defaultValue
- The checkbox default value- Returns:
- The checkbox item component
- If
-
setReadOnly
Sets if the checkbox is read-only. If the checkbox is read-only, the user won't be able to modify the item's value.- Overrides:
setReadOnly
in classFormItem<Boolean,
CheckboxItem> - Parameters:
readOnly
-true
if the checkbox is read-only. Otherwise, the checkbox can be modified.- Returns:
- The checkbox item component
-
setReverseShow
-