Class HtmlCheckBoxInput

All Implemented Interfaces:
Serializable, Cloneable, DisabledElement, FormFieldWithNameHistory, LabelableElement, SubmittableElement, ValidatableElement, Element, Node

public class HtmlCheckBoxInput extends HtmlInput implements LabelableElement
Wrapper for the HTML element "input".
See Also:
  • Method Details

    • isChecked

      public boolean isChecked()
      Returns true if this element is currently selected.
      Overrides:
      isChecked in class HtmlInput
      Returns:
      true if this element is currently selected
    • reset

      public void reset()
      Returns the value of this element to the default value or checked state (usually what it was at the time the page was loaded, unless it has been modified via JavaScript).
      Specified by:
      reset in interface SubmittableElement
      Overrides:
      reset in class HtmlInput
      See Also:
    • setChecked

      public Page setChecked(boolean isChecked)
      Sets the checked attribute, returning the page that occupies this input's window after setting the attribute. Note that the returned page may or may not be the original page, depending on the presence of JavaScript event handlers, etc.
      Overrides:
      setChecked in class HtmlInput
      Parameters:
      isChecked - true if this element is to be selected
      Returns:
      the page that occupies this input's window after setting the attribute
    • doClickStateUpdate

      protected boolean doClickStateUpdate(boolean shiftKey, boolean ctrlKey) throws IOException
      This method implements the control state update part of the click action.

      The default implementation only calls doClickStateUpdate on parent's DomElement (if any). Subclasses requiring different behavior (like HtmlSubmitInput) will override this method.

      Overrides:
      doClickStateUpdate in class DomElement
      Parameters:
      shiftKey - true if SHIFT is pressed
      ctrlKey - true if CTRL is pressed
      Returns:
      true if doClickFireEvent method has to be called later on (to signal, that the value was changed)
      Throws:
      IOException - if an IO error occurs
    • doClickFireChangeEvent

      protected void doClickFireChangeEvent()
      This method implements the control onchange handler call during the click action.
      Overrides:
      doClickFireChangeEvent in class DomElement
    • isStateUpdateFirst

      protected boolean isStateUpdateFirst()
      First update the internal state of checkbox and then handle "onclick" event. Returns true if state updates should be done before onclick event handling. This method returns false by default, and is expected to be overridden to return true by derived classes like HtmlCheckBoxInput.
      Overrides:
      isStateUpdateFirst in class DomElement
      Returns:
      true if state updates should be done before onclick event handling
    • preventDefault

      protected void preventDefault()
      This method is called if the current fired event is canceled by preventDefault().

      The default implementation does nothing.

      Overrides:
      preventDefault in class DomElement
    • setDefaultValue

      public void setDefaultValue(String defaultValue)
      Sets the default value to use when this element gets reset, if applicable. Also sets the value to the new default value.
      Specified by:
      setDefaultValue in interface SubmittableElement
      Overrides:
      setDefaultValue in class HtmlInput
      Parameters:
      defaultValue - the default value to use when this element gets reset, if applicable
      See Also:
    • setValue

      public void setValue(String newValue)
      Sets the value. Also sets the default value.
      Overrides:
      setValue in class HtmlInput
      Parameters:
      newValue - the new value
    • setDefaultChecked

      public void setDefaultChecked(boolean defaultChecked)
      Sets the default checked state to use when this element gets reset, if applicable. The default implementation is empty; only checkboxes and radio buttons really care what the default checked value is.
      Specified by:
      setDefaultChecked in interface SubmittableElement
      Parameters:
      defaultChecked - the default checked state to use when this element gets reset, if applicable
      See Also:
    • isDefaultChecked

      public boolean isDefaultChecked()
      Returns the default checked state to use when this element gets reset, if applicable. The default implementation returns false; only checkboxes and radio buttons really care what the default checked value is.
      Specified by:
      isDefaultChecked in interface SubmittableElement
      Overrides:
      isDefaultChecked in class HtmlInput
      Returns:
      the default checked state to use when this element gets reset, if applicable
      See Also:
    • getInternalValue

      protected Object getInternalValue()
      Overrides:
      getInternalValue in class HtmlInput
      Returns:
      returns the raw value
    • setAttributeNS

      protected void setAttributeNS(String namespaceURI, String qualifiedName, String attributeValue, boolean notifyAttributeChangeListeners, boolean notifyMutationObservers)
      Sets the value of the attribute specified by namespace and qualified name.
      Overrides:
      setAttributeNS in class HtmlInput
      Parameters:
      namespaceURI - the URI that identifies an XML namespace
      qualifiedName - the qualified name (prefix:local) of the attribute
      attributeValue - the value of the attribute
      notifyAttributeChangeListeners - to notify the associated HtmlAttributeChangeListeners
      notifyMutationObservers - to notify MutationObservers or not
    • propagateClickStateUpdateToParent

      protected boolean propagateClickStateUpdateToParent()
      Overrides:
      propagateClickStateUpdateToParent in class HtmlInput
      Returns:
      true or false
      See Also:
    • isValueMissingValidityState

      public boolean isValueMissingValidityState()
      Specified by:
      isValueMissingValidityState in interface ValidatableElement
      Overrides:
      isValueMissingValidityState in class HtmlInput
      Returns:
      true if the element has a required attribute, but no value, or false otherwise. If true, the element matches the :invalid CSS pseudo-class.