<netui:radioButtonGroup> Tag

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

Syntax

<netui:radioButtonGroup
    dataSource="dataSource"
    [defaultValue="defaultValue"]
    [disabled="disabled"]
    [labelStyle="labelStyle"]
    [labelStyleClass="labelStyleClass"]
    [optionsDataSource="optionsDataSource"]
    [orientation="orientation"]
    [repeater="repeater"]
    [style="style"]
    [styleClass="styleClass"] />

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
Required: Yes  |   Supports runtime evaluation: No  |   Data bindable:

defaultValue
Required: No  |   Supports runtime evaluation: Yes  |   Data bindable:

disabled
Required: No  |   Supports runtime evaluation: Yes  |   Data bindable:

labelStyle
Required: No  |   Supports runtime evaluation: Yes  |   Data bindable:

labelStyleClass
Required: No  |   Supports runtime evaluation: Yes  |   Data bindable:

optionsDataSource
Required: No  |   Supports runtime evaluation: Yes  |   Data bindable:

orientation
Required: No  |   Supports runtime evaluation: Yes  |   Data bindable:

repeater
Required: No  |   Supports runtime evaluation: Yes  |   Data bindable:

style
Required: No  |   Supports runtime evaluation: Yes  |   Data bindable:

styleClass
Required: No  |   Supports runtime evaluation: Yes  |   Data bindable:


 
Example

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>