Radio Button Group
A group of radio buttons. It is usually used to select one item out of many choices. The list of choices can be statically defined, or can be bound to data storage such as a database or a bean (or a combination of both). The entire group is usually bound to data storage. When a page with radio buttons is submitted, the value of the selected radio button is stored in the specified location (for example, a column in the database or a property of the bean).
Component at design time
Drag and drop a
Radio Button Group component onto the page:
The
Radio Button Group component looks like this on the page:
Component at runtime
The
Radio Button Group component looks like this on the page during runtime:
Properties and All Attributes views
The Properties view for a component shows the most common set of attributes you can set on a component, and, depending on the component, you might also see options for adding controls, actions, or other components. To open the Properties view, click
Window | Show View | Properties.
These common attributes for the Radio Button Group component display on the h:selectOneRadio and Accessibility tabs in the Properties view. See the All Radio Button Group attributes table for a complete list of attributes. Additional configuration options for radio button items are on the h:selectOneRadio tab:
Table 1. Radio Button Group configuration options Configuration option
Description
Add a choice for each radio button in the group
Allows you to specify the names, values and order of buttons in the radio button group component.
Invalid values for selectOne components
Note:
The JSF lifecycle does not validate values when a page is initially rendered, as per the JSF standard. For example:
<h:inputText id="text2" styleClass="inputText" value="#{pc_Sa_RATLC00298618.myBean.myBigDecimal04}"> <hx:convertNumber/> <f:validateDoubleRange minimum="10.0" maximum="99.0"> </f:validateDoubleRange> </h:inputText>If the value initially resolves to something that is not in the specified range, the JSF tools will not mark an error (in an <h:message> tag). It is assumed that an invalid value is deliberately being used so that a user can correct it or to display an input message.When the tag with an invalid value is a selectOne component, such as a combo box, a list box or a radio button group, an initial value is not set on the HTML tag (no option is selected) when the page is rendered. This is because an option that matches the invalid value cannot be located.
The browser will display nothing selected in the list box or radio button group since it is assumed that you are trying to force a user to choose a value. When the page is submitted, a value is not submitted (no selection) if non-valid choice has been made. If the field is marked as
"required", an error will be generated.
In the case of a combo box, the same thing is done, but the browser behavior differs. If a combo box has an invalid selection, the browser makes the first value the selection. As a result, when the page is submitted, a valid value is always submitted.
The All Attributes view shows a table of all the attributes you can set on a component, which includes those attributes you can access from the Properties view. To switch to the All Attributes view, click the
All Attributes icon in the upper right corner of the Properties view.
Table 2. All Radio Button Group attributes Attribute name
Represented in Properties view by
Description
accesskey
Accessibility>Access Key
Specifies a single keyboard key as an access key. Pressing the specified access key at runtime gives focus to this component. Pressing ALT plus the specified access key at runtime gives focus to this component (or executes the component if it is a kind of button).
binding
Not represented
An expression that binds the component's instance (usually a user interface component) to a bean property (usually in the backing file).
border
Not represented
Specifies, in pixels, the size of the border for the table.
converter
Not represented
Specifies the data type to which the value is converted. The JavaServer Faces implementation provides a set of Converter implementations that you can use to convert your component data to a type not supported by its renderer.
dir
Not represented
Specifies the component's direction when rendered at runtime. The values can be either:
If the direction is not specified, a direction appropriate to the encoding of the component is used.
- ltr - left to right
- rtl - right to left
disabled
Not represented
If disabled is set to true, the component is displayed at runtime but is not functional. If left blank, the default value is false.
disabledClass
Not represented
Alternative CSS class names associated with the component The situation in which these are used can be determined from the names.
enabledClass
Not represented
Alternative CSS class names associated with the component The situation in which these are used can be determined from the names.
id
ID
Assigns a name to a component. Should be a unique name within a JSP.
immediate
Not represented
If true, skip straight to render phase of life cycle.
lang
Not represented
The language of the component's value(s) and text content. If omitted, the language is inherited from the containing tags (notably the view. Specified as an ISO-standard language abbreviation code. For example, "en" for English, "en-US" for American English, "fr" for French, "de" for German.
Note: This does not "translate" the text in the component, rather, it identifies the language of the component so that operations such as searching, sorting, collating and the like are done correctly.
layout
Direction
Specifies whether the component is oriented horizontally or vertically at runtime:
- Horizontal
- Vertical
readonly
Not represented
Specifies that the value of the component cannot be changed from its initial value.
rendered
Not represented
Can be set to true or false:
- false - Component will not be rendered to the browser at runtime.
- true - Component will get rendered. This is the default value.
required
Not represented
The component must be specified. Check this to require the user to enter a value.
styleClass
Style: Classes
Space-separated list of CSS style classes to be applied when this element is rendered. This value must be passed through as the class attribute on generated markup. Defines the classes (such as style sheets) of the selected component. This may be done manually, or by clicking the button and selecting the desired Classes from within the window.
style
Style: Props
Specifies CSS style information for the component (for example, style="font-size : 8pt ; color : red"). Defines the properties (such as font and color) of the selected component. This may be done manually, or by clicking the button and selecting the desired properties from within the window.
tabindex
Accessibility>Tab order index
Specifies the position of the component in the tabbing order in the JSP. This value must be a number between 0 and 32767.
title
Accessibility>Title
Specifies the title text, shown in browser as a tooltip at runtime. Used by a browser as the alternative text of a component if the alternative text is not specified.
validator
Not represented
A method (represented by a MethodBinding expression) that accepts FacesContext, UIComponent, and Object parameters. It is called during the validation process to ensure that value of the component is correct.
value
Value
Specifies the initial text value for the component displayed at runtime. Contains information to be displayed, in the form of a specified value or a pointer to a dynamic value.
valueChangeListener
Not represented
Method to be notified when value of component has changed.
Related tasks
Adding selection lists to a Faces JSP file