public class CheckBox extends AbstractField<Boolean> implements FieldEvents.BlurNotifier, FieldEvents.FocusNotifier
| Modifier and Type | Class and Description |
|---|---|
static class |
CheckBox.CheckBoxInputElement
The inner input element of the CheckBox.
|
static class |
CheckBox.CheckBoxLabelElement
The inner label element of the CheckBox.
|
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<V>Component.ErrorEvent, Component.Event, Component.Focusable, Component.ListenerClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListenerSizeable.UnitDESIGN_ATTR_PLAIN_TEXTSIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS| Constructor and Description |
|---|
CheckBox()
Creates a new checkbox.
|
CheckBox(String caption)
Creates a new checkbox with a set caption.
|
CheckBox(String caption,
boolean initialState)
Creates a new checkbox with a caption and a set initial state.
|
| Modifier and Type | Method and Description |
|---|---|
Registration |
addBlurListener(FieldEvents.BlurListener listener)
Adds a
BlurListener to the Component which gets fired
when a Field loses keyboard focus. |
Registration |
addFocusListener(FieldEvents.FocusListener listener)
Adds a
FocusListener to the Component which gets fired
when a Field receives keyboard focus. |
protected void |
doSetValue(Boolean value)
Sets the value of this field.
|
protected Collection<String> |
getCustomAttributes()
Returns a collection of attributes that should not be handled by the
basic implementation of the
AbstractComponent.readDesign(Element, DesignContext)
and AbstractComponent.writeDesign(Element, DesignContext) methods. |
Boolean |
getEmptyValue()
Returns the value that represents an empty value.
|
CheckBox.CheckBoxInputElement |
getInputElement()
Returns the
CheckBox.CheckBoxInputElement element to manipulate the style
name of the input element of the CheckBox. |
CheckBox.CheckBoxLabelElement |
getLabelElement()
Returns the
CheckBox.CheckBoxLabelElement element to manipulate the style
name of the label element of the CheckBox. |
protected CheckBoxState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
protected CheckBoxState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
Boolean |
getValue()
Returns the current value of this object.
|
void |
readDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Reads the component state from the given design.
|
void |
setValue(Boolean value)
Sets the value of this CheckBox.
|
protected boolean |
setValue(Boolean value,
boolean userOriginated)
Sets the value of this CheckBox.
|
void |
writeDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Writes the component state to the given design.
|
addValueChangeListener, createValueChange, focus, getTabIndex, isDifferentValue, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible, setTabIndexaddContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthUndefinedaddAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstateclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitclear, getDefaultValidator, getOptionalValue, isEmptyaddListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisibleaddAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdgetHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefinedpublic CheckBox()
public CheckBox(String caption)
caption - the Checkbox caption.public CheckBox(String caption, boolean initialState)
caption - the caption of the checkboxinitialState - the initial state of the checkboxpublic Boolean getValue()
HasValueImplementation note: the implementing class should document whether null values may be returned or not.
public void setValue(Boolean value)
getValue(), fires a ValueChangeEvent. Throws
NullPointerException if the value is null.setValue in interface HasValue<Boolean>setValue in class AbstractField<Boolean>value - the new value, not nullNullPointerException - if value is nullprotected boolean setValue(Boolean value, boolean userOriginated)
getValue(), fires a ValueChangeEvent. Throws
NullPointerException if the value is null.setValue in class AbstractField<Boolean>value - the new value, not nulluserOriginated - true if this event originates from the client,
false otherwise.true if the value was updated, false
otherwiseNullPointerException - if value is nullpublic Boolean getEmptyValue()
HasValue
By default HasValue is expected to support null as empty
values. Specific implementations might not support this.
getEmptyValue in interface HasValue<Boolean>Binder#bind(HasValue, ValueProvider, Setter)protected CheckBoxState getState()
AbstractComponentgetState in class AbstractField<Boolean>protected CheckBoxState getState(boolean markAsDirty)
AbstractClientConnectorgetState in class AbstractField<Boolean>markAsDirty - true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()protected void doSetValue(Boolean value)
AbstractFieldIllegalArgumentException if the value is invalid. Typically saves
the value to shared state.doSetValue in class AbstractField<Boolean>value - the new value of the fieldpublic Registration addBlurListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifierBlurListener to the Component which gets fired
when a Field loses keyboard focus.addBlurListener in interface FieldEvents.BlurNotifierlistener - the blur listener to add, not nullFieldEvents.BlurListener,
Registrationpublic Registration addFocusListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifierFocusListener to the Component which gets fired
when a Field receives keyboard focus.addFocusListener in interface FieldEvents.FocusNotifierlistener - the focus listener to add, not nullFieldEvents.FocusListener,
Registrationpublic void readDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
ComponentThe component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.
It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.
This method must not modify the design.
readDesign in interface ComponentreadDesign in class AbstractField<Boolean>design - The element to obtain the state fromdesignContext - The DesignContext instance used for parsing the designprotected Collection<String> getCustomAttributes()
AbstractComponentAbstractComponent.readDesign(Element, DesignContext)
and AbstractComponent.writeDesign(Element, DesignContext) methods. Typically these
are handled in a custom way in the overridden versions of the above
methodsgetCustomAttributes in class AbstractField<Boolean>public void writeDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
ComponentThe component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.
This method must not modify the component state.
writeDesign in interface ComponentwriteDesign in class AbstractField<Boolean>design - The element to write the component state to. Any previous
attributes or child nodes are not cleared.designContext - The DesignContext instance used for writing the designpublic CheckBox.CheckBoxInputElement getInputElement()
CheckBox.CheckBoxInputElement element to manipulate the style
name of the input element of the CheckBox.CheckBox.CheckBoxInputElement, not null.public CheckBox.CheckBoxLabelElement getLabelElement()
CheckBox.CheckBoxLabelElement element to manipulate the style
name of the label element of the CheckBox.CheckBox.CheckBoxLabelElement, not null.Copyright © 2019 Vaadin Ltd. All rights reserved.