# <netui:radioButtonGroup> Tag

Renders a collection of radiobutton options and handles the data binding of their values.

## Syntax

<netui:radioButtonGroup
dataSource="expression_datasource"
[defaultValue="string_or_expression_default"]
[disabled="boolean_disabled"]
[labelStyle="string_labelStyle"]
[labelStyleClass="string_class"]
[optionsDataSource="expression_datasource"]
[style="string_Style"]
[styleClass="string_Class"]
[tagId="string_tagId"] />

## Description

Renders a collection of radiobutton options and handles the data binding of their values.

The <netui:radioButtonGroup> tag can generate a set of radiobutton options in two ways:

> 1. they can be dynamically generated by pointing the <netui:radioButtonGroup> tag at a java.util.HashMap or String[] object
> 2. they can be statically generated by providing a set of children <netui:radioButtonOption> tags

Dynamically Generated Radiobutton Options

You can dynamically generate a set of radionbutton options by pointing the <netui:radioButtonGroup> tag at a HashMap (or any object that implements the java.util.Map interface).

          public HashMap hashMap = new HashMap();
          hashMap.put("value1", "Display Text 1");
          hashMap.put("value2", "Display Text 2");
          hashMap.put("value3", "Display Text 3");

To point the <netui:radioButtonGroup> at the Map object use the `optionsDataSource` attribute.

         <netui:radioButtonGroup
              optionsDataSource="{pageFlow.hashMap}">

In the generated radiobutton options, the display text and the submitted value can be made to differ. The HashMap keys will form the submitted values, while the HashMap entries will form the display texts.

         <input type="radio" value="value1">Display Text 1</input>
         <input type="radio" value="value2">Display Text 2</input>
         <input type="radio" value="value3">Display Text 3</input>

Note that you can point the <netui:radioButtonGroup> tag at a String[] object. A set of radiobutton options will be generated, but there will be no difference between the display texts and the submitted values.

Statically Generated Radiobutton Options

To statically generate radiobutton options, place a set of <netui:radioButtonOption> tags inside the <netui:radioButtonGroup> tag.

        <netui:radioButtonGroup dataSource="{actionForm.selection}">
            <netui:radioButtonOption value="value1">Display Text 1</netui:radioButtonOption><br>
            <netui:radioButtonOption value="value2">Display Text 2</netui:radioButtonOption><br>
            <netui:radioButtonOption value="value3">Display Text 3</netui:radioButtonOption><br>
        </netui:radioButtonGroup>

Submitting Radionbutton Options

A <netui:radioButtonGroup> is submitted as a String value. Use the `dataSource` attribute to submit to a String object.

         <netui:radioButtonGroup dataSource="{actionForm.selection}">

In this case, the <netui:radioButtonGroup> submits to a String field of a Form Bean.

         public static class ProcessDataForm extends FormData
         {
             private String selection;

             public void setSelection(String selection)
             {
                 this.selection = selection;
             }

             public String getSelection()
             {
                 return this.selection;
             }
         }

## Attributes

dataSource | The `dataSource` attribute determines both (1) the source of populating data for the tag and (2) the object to which the tag submits data. For example, assume that the Controller file (= JPF file) contains a Form Bean with the property foo. Then the following <netui:textBox> tag will (1) draw populating data from the Form Bean's foo property and (2) submit user defined data to the same property. `<netui:textBox dataSource="{actionForm.foo}" />` The `dataSource` attribute takes either a data binding expression or the name of a Form Bean property. In the above example, `<netui:textBox dataSource="foo" />` would have the exactly same behavior. When the tag is used to submit data, the data binding expression must refer to a Form Bean property. In cases where the tag is not used to submit data, but is used for displaying data only, the data binding expression need not refer to a Form Bean property. For example, assume that myIterativeData is a member variable on the Controller file ( = JPF file). The following <netui-data:repeater> tag draws its data from myIterativeData. `<netui-data:repeater dataSource="{pageFlow.myIterativeData}">`
Required | Supports runtime expression evaluation | Data bindable
Yes | No | Read / Write
defaultValue | Use in <netui:checkBoxGroup>, <netui:checkBox>, <netui:radioButtonGroup>, and <netui:select> tags Sets the preselected value or values. The `defaultValue` attribute takes either a String literal or a data binding expression. If the `defaultValue` attribute has a String value (or if the data binding expression points to a String), then a single value will be preselected. If the `defaultValue` attribute points to a String[] object (or any object which can be iterated over), then multiple values will be preselected. Use in <netui:textArea> and <netui:textBox> tags Sets the initial display text. The `defaultValue` attribute takes either a String literal or a data binding expression that points to a String.
Required | Supports runtime expression evaluation | Data bindable
No | No | Read / Write
disabled | Boolean. If set to true, the group will be visible, but diabled.
Required | Supports runtime expression evaluation | Data bindable
No | No | Read Only
labelStyle | The style of the label for each contained <netui:radioButtonOption> tag.
Required | Supports runtime expression evaluation | Data bindable
No | No | No
labelStyleClass | The class of the labels for each contained <netui:radioButtonOption> tag.
Required | Supports runtime expression evaluation | Data bindable
No | No | No
optionsDataSource | The `optionsDataSource` attribute determines the set of options presented to the user. In a <netui:select> tag, the options are rendered as a set of <netui:option> tags. In a <netui:checkBoxGroup> tag, the options are rendered as a set of <netui:checkBox> tags. In a <netui:radioButtonGroup> tag, the options are rendered as a set of <netui:radionButton> tags. The options can be determined dynamically by pointing the `optionsDataSource` at a String[] object or an object that implements java.util.Map. In either case, a set of options will be rendered based on the content of the String[] or java.util.Map object. One option will be rendered for each element in the String[] or for each entry in the java.util.Map. If a java.util.Map object is used, the display name and underlying value of each option may be set independently. (The display name will be rendered based on the value of each Map entry; the underlying value will be rendered based on the key of each Map entry.) If a String[] object is used, the display name and underlying value of each option will be identical. See the Description and Sample sections of this topic for details. Use a data binding expression to point the `optionsDataSource` at the String[] or java.util.Map object. For instance, assuming that `myStrArr` is a member variable of the Controller file (= the JPF file), then the following `optionsDataSource` points at `myStrArr`. `optionsDataSource={pageFlow.myStrArr}`
Required | Supports runtime expression evaluation | Data bindable
No | No | Read Only
style | Sets the style of the rendered HTML tag.
Required | Supports runtime expression evaluation | Data bindable
No | No | No
styleClass | The class of the rendered HTML tag.
Required | Supports runtime expression evaluation | Data bindable
No | No | No
tagId | String value. Sets the `id` (or `name`) attribute of the rendered HTML tag. Note that the real id attribute rendered in the browser may be changed by the application container (for example, Portal containers may change the rendered id value to ensure the uniqueness of id's on the page). In this case, the real id rendered in the browser may be looked up through the JavaScript function getNetuiTagName( tagId, tag ). For example, assume that some tag's `tagId` attribute is set to `foo`.
        <netui:textBox tagId="foo" />
Then the following JavaScript function will return the real id attribute rendered in the browser:
        getNetuiTagName( "foo", this )
To get a <netui:form> element and all of its children elements in JavaScript, use the same JavaScript function `getNetuiTagName( tagId, tag )`. For example, assume that there is a <netui:form> whose tagId attribute is set to `bar`.
        <netui:form tagId="bar" >
Then the following JavaScript function will return the <netui:form> element and its children (packaged as an array).
        document[getNetuiTagName( "bar", this )]
To retreive the value entered into a <netui:textBox> within the <netui:form> tag, use the following JavaScript expression.
        document[getNetuiTagName("bar", this)][getNetuiTagName("foo", this)].value
The second parameter ensures that the JavaScript function begins its search within the correct Portlet scope. Pass the JavaScript keyword `this` as the second parameter. For detailed information on using the function `getNetuiTagName( tagId, tag )` see Using JavaScript in Page Flow and Portal Applications.
Required | Supports runtime expression evaluation | Data bindable
No | Yes | No

## Sample

In this sample, a <netui:radioButtonGroup> tag draws a set of options from a HashMap object.

             <netui:radioButtonGroup
              optionsDataSource="{pageFlow.hashMap}"
              dataSource="{actionForm.selection}" />

Assuming that the `optionsDataSource` attribute refers to the following HashMap object...

         public HashMap hashMap = new HashMap();
         protected void onCreate()
         {
             hashMap.put("value1", "Display Text 1");
             hashMap.put("value2", "Display Text 2");
             hashMap.put("value3", "Display Text 3");
         }

...then the following HTML will be generated in the browser...

         <netui:radioButtonGroup dataSource="{actionForm.selection}">
            <netui:radioButtonOption value="value1">Display Text 1</netui:radioButtonOption><br>
            <netui:radioButtonOption value="value2">Display Text 2</netui:radioButtonOption><br>
            <netui:radioButtonOption value="value3">Display Text 3</netui:radioButtonOption><br>
        </netui:radioButtonGroup>

## Sample Code

[BEA_HOME]/weblogic81/samples/SamplesApp/WebApp/tagSamples/netui/radioButtons/

## Related Topics

<netui:radionButton> Tag Samples

<netui:radioButtonOption> Tag