You can drag the Radio Button component from the Palette's Basic category to the Visual Designer to create a single radio button with an optional label.
Radio Button components are typically used in a group. If you want a set of radio buttons that is preformatted with labels, use a Radio Button Group component instead.
You can also drop the radio button on a container component, like a table cell or group box.
A radio button can represent any object, whether the object is of a predefined class like Boolean
, Byte
, Character
, Double
, Float
, Integer
, Long
, Short
, String
, or of a class defined by the user. A radio button can also represent a primitive value.
A Boolean
value is useful for indicating whether an item, such as a table row, is selected. A String
value is useful for passing values for radio button selections made in the interface. An application defined Object
value or class instance can be used to hold more information related to a radio button selection.
A single radio button can be used to represent several types of data:
A group of radio buttons can be used to represent:
The radio button component can be useful in situations where the Radio Button Group component layout is not desirable, such as in a table row.
The radio button component uses both the selected
and selectedValue
properties to pass information about the radio button's selection status. The selected
property is used to indicate that the radio button is selected, and an indication that the button is selected is displayed in the page. The selectedValue
property is used to pass a data value for the radio button. A radio button is considered to be selected when the value of the selected
property is equal to the value of the selectedValue
property. You can display a radio button as selected on the initial viewing of the page by assigning the same value to the selectedValue
and the selected
properties.
If the selectedValue
property is not specified or its value is null
, the radio button behaves like a boolean control, as described in the next section.
A value binding expression that evaluates to a primitive value can be assigned to the selected
and selectedValue
properties.
If the selectedValue
property is not specified or its value is null
, the radio button behaves like a boolean control.
To use the radio button as a boolean control, do not specify a value for the selectedValue
property. The radio button is selected if the selected
property is not null and has the value of a true Boolean
instance or a boolean primitive value. If the radio button is not selected, the value of the selected property is a false Boolean
instance or boolean primitive.
true
values. The selectedValue
property can be assigned an application-defined object value to represent the value of a selected radio button. If the radio button is selected, the value of the selected
property is assigned the value of the selectedValue
property.
If the value of the selectedValue
property is an application-defined object, a converter must be registered to convert to and from a String
value. The converter is used to encode the radio button value as the value of the HTML <input>
element and to decode the submitted value in a request. In addition the object must support an equals
() method that returns true
when the value of the selectedValue
property is compared to the selected
property value to detect a selected radio button.
The name
property determines whether a radio button is part of a group. All radio buttons in a group have the same name
property value. The group behaves like a single selection list in which only one radio button can be selected. The value of the name
property must be unique within the scope of the page containing the radio buttons.