Class WCheckBox

    • Constructor Detail

      • WCheckBox

        public WCheckBox()
        Creates an initially unselected check box with no set text.
      • WCheckBox

        public WCheckBox​(boolean selected)
        Creates a check box with the specified text and selection state.
        Parameters:
        selected - if true, the check box is initially selected; otherwise, the check box is initially unselected
    • Method Detail

      • setGroup

        public void setGroup​(WComponentGroup<WCheckBox> group)
        Sets the checkbox group. When a single grouped checkbox is targeted with a WSelectToggle, all checkboxes in that group will be updated.
        Parameters:
        group - The group to set.
      • toggleSelection

        public final void toggleSelection​(boolean selected)
        Description copied from interface: SelectionToggleable
        Sets the selections for this component.
        Specified by:
        toggleSelection in interface SelectionToggleable
        Parameters:
        selected - if true, select everything. If false, deselect everything.
      • doHandleRequest

        protected boolean doHandleRequest​(Request request)

        Override handleRequest in order to perform processing for this component. This implementation checks the checkbox state in the request.

        Specified by:
        doHandleRequest in class AbstractInput
        Parameters:
        request - the request being responded to.
        Returns:
        true if the check box has changed
      • getRequestValue

        public Boolean getRequestValue​(Request request)
        Provide the value of the component on the Request.

        If the component is not on the request, the components current value will be provided.

        Specified by:
        getRequestValue in interface Input
        Parameters:
        request - the request being responded to.
        Returns:
        the value of this component on the Request, or its current state if it is not on the request.
      • getValue

        public Boolean getValue()
        Provide the value of the component returned by DataBound.getData() in the correct format.

        If required, this method can convert the data into the correct type and also do any validation before the value is used.

        Specified by:
        getValue in interface Input
        Overrides:
        getValue in class AbstractInput
        Returns:
        the value of the component returned by DataBound.getData() in the correct format.
      • isSelected

        public boolean isSelected()
        Returns the state of the check box. True if selected, false if not.
        Returns:
        true if the check box is selected, otherwise false
      • setSelected

        public void setSelected​(boolean selected)
        Sets the state of the check box.
        Parameters:
        selected - true if the check box is selected, otherwise false
      • setSubmitOnChange

        @Deprecated
        public void setSubmitOnChange​(boolean submitOnChange)
        Deprecated.
        1.4.0 as it results in a level A accessibility problem See https://www.w3.org/TR/UNDERSTANDING-WCAG20/consistent-behavior-unpredictable-change.html.
        Sets whether the form should be submitted when the checkbox is checked/unchecked. This sets the default option SubmitOnChange seen by all user sessions.
        Parameters:
        submitOnChange - true to submit the form on change.
      • isSubmitOnChange

        @Deprecated
        public boolean isSubmitOnChange()
        Deprecated.
        1.4.0 as it results in a level A accessibility problem See https://www.w3.org/TR/UNDERSTANDING-WCAG20/consistent-behavior-unpredictable-change.html.
        Indicates whether the form should be submitted when the checkbox is checked/unchecked.
        Returns:
        true if the form should be submitted on change.
      • getComponentModel

        protected WCheckBox.CheckBoxModel getComponentModel()
        Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.
        Overrides:
        getComponentModel in class AbstractInput
        Returns:
        the effective component model
      • getOrCreateComponentModel

        protected WCheckBox.CheckBoxModel getOrCreateComponentModel()
        Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.
        Overrides:
        getOrCreateComponentModel in class AbstractInput
        Returns:
        the model for this component