Class RadioButtonGroup

    • Constructor Detail

      • RadioButtonGroup

        public RadioButtonGroup()
    • Method Detail

      • getValue

        public String 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.
      • doHandleRequest

        protected boolean doHandleRequest​(Request request)
        This method will only processes a request where the group is on the request and has no value. If the group has no value, then none of the group's radio buttons will be triggered to process the request.
        Specified by:
        doHandleRequest in class AbstractInput
        Parameters:
        request - the request being responded to.
        Returns:
        true if the group has changed, otherwise false
      • setFocussed

        public void setFocussed()
        The radio button group does not set focus. It allows the radio buttons to set their own focus if they are selected.
        Specified by:
        setFocussed in interface WComponent
        Overrides:
        setFocussed in class AbstractWComponent
      • getRequestValue

        public String 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.
      • isPresent

        protected boolean isPresent​(Request request)
        Determine if this component is on the Request.
        Overrides:
        isPresent in class AbstractInput
        Parameters:
        request - the request being responded to.
        Returns:
        true if this component is on the Request, otherwise return false.
      • getSelectedValue

        public String getSelectedValue()
        Retrieves the selected value for this group.
        Returns:
        the value of the selected radio button, or null if there is no selection.
      • setSelectedValue

        public void setSelectedValue​(String value)
        Sets the selected value for this group.
        Parameters:
        value - the selected value, or null to clear the selection.
      • 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 selection changes.
        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 selection changes.
        Returns:
        true if the form should be submitted on change.
      • addRadioButton

        public WRadioButton addRadioButton​(Object value)
        This method will add a radio button to the group with the given value. The value must be unique for the group.

        The radio button returned by this method must be added to the required location in the UI Component tree.

        The radio button group uses the String representation of the radio button's value to identify which button has been selected. As the string representation of the radio button's value is sent to the client, be mindful that it should not be too large.

        Parameters:
        value - a unique value for the radio button.
        Returns:
        the radio button that was added to the group
      • addRadioButton

        public WRadioButton addRadioButton()
        This method will add a radio button to the group.

        Unlike {addRadioButton(Object), which requires a value to be passed in, this method has no value passed in for the radio button, as it is expected the radio button will be used with a WRepeater and will get its value from a bean. The bean property will default to ".", but can be set to the appropriate bean property after being returned.

        The radio button returned by this method must be added to the required location in the UI Component tree.

        The radio button group uses the String representation of the radio button's value to identify which button has been selected. As the string representation of the radio button's value is sent to the client, be mindful that it should not be too large.

        Returns:
        the radio button that was added to the group