Class WToggleButton

    • Constructor Detail

      • WToggleButton

        public WToggleButton()
        Create a default WToggleButton.
      • WToggleButton

        public WToggleButton​(boolean selected)
        Create a WToggleButton in a given selected state.
        Parameters:
        selected - the selected state
      • WToggleButton

        public WToggleButton​(String text)
        Create a WToggleButton with specific text.
        Parameters:
        text - the text to show on the toggle button
      • WToggleButton

        public WToggleButton​(String text,
                             boolean selected)
        Create a WToggleButton with specified text and selected state.
        Parameters:
        selected - thee selected state of the toggle button where true is selected
        text - the text to show on the toggle button
    • Method Detail

      • setText

        public final void setText​(String text)
        Sets the button text.
        Parameters:
        text - the button text, using MessageFormat syntax
      • getText

        public String getText()
        Returns:
        the text to show on the toggle button
      • isMandatory

        public boolean isMandatory()
        A WToggleButton cannot be mandatory as a mandatory toggle button is one which must be set into a selected state and if a control must be set into a selected state it is not a selection control.
        Specified by:
        isMandatory in interface Mandatable
        Overrides:
        isMandatory in class AbstractInput
        Returns:
        false
      • setSubmitOnChange

        public void setSubmitOnChange​(boolean submitOnChange)
        Must not set submitOnChange on a WToggleButton. If you need a button which submits the form use WButton.
        Overrides:
        setSubmitOnChange in class WCheckBox
        Parameters:
        submitOnChange - not used
      • isSubmitOnChange

        public boolean isSubmitOnChange()
        Description copied from class: WCheckBox
        Indicates whether the form should be submitted when the checkbox is checked/unchecked.
        Overrides:
        isSubmitOnChange in class WCheckBox
        Returns:
        false as WToggleButton cannot have submitOnChange: that would be a WButton
      • getComponentModel

        protected WToggleButton.ToggleButtonModel 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 WCheckBox
        Returns:
        the effective component model
      • getOrCreateComponentModel

        protected WToggleButton.ToggleButtonModel 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 WCheckBox
        Returns:
        the model for this component