NetUI Tag Library Documentation (Version 1.0.1)

netui
netui:radioButtonGroup Tag

Renders a collection of radiobutton options as <input type="radio"> and handles the data binding of their values.

Syntax

<netui:radioButtonGroup
    dataSource="string_dataSource"
    [defaultValue="string_or_expression_default"]
    [disabled="boolean_disabled"]
    [labelStyle="string_labelStyle"]
    [labelStyleClass="string_labelStyleClass"]
    [optionsDataSource="expression_optionsDataSource"]
    [orientation="string_orientation"]
    [repeater="boolean_repeater"]
    [style="string_style"]
    [styleClass="string_styleClass"] >
    ... JSP content ...
</netui:radioButtonGroup>

Description

Renders a collection of radiobutton options as <input type="radio"> 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 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 Map interface).

For example, if you define a HashMap object and get method in the Controller file...

    public HashMap hashMap = new HashMap();

    protected HashMap getHashMap()
    {
        return hashMap;
    }

    protected void onCreate()
    {
        hashMap.put("value1", "Display Text 1");
        hashMap.put("value2", "Display Text 2");
        hashMap.put("value3", "Display Text 3");
    }
...point the <netui:radioButtonGroup> at the Map object using the optionsDataSource attribute.
    <netui:radioButtonGroup
            dataSource="actionForm.selection"
            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" name="wlw-radio_button_group_key:{actionForm.selection}" value="value1">Display Text 1</input>
    <input type="radio" name="wlw-radio_button_group_key:{actionForm.selection}" value="value2">Display Text 2</input>
    <input type="radio" name="wlw-radio_button_group_key:{actionForm.selection}" 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 Data

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  |   Type: String  |   Supports runtime evaluation / JSP Expression Language: No

An expression to be evaluated. It determines the source of populating data for the tag
defaultValue
Required: No  |   Type: String  |   Supports runtime evaluation / JSP Expression Language: Yes

The String literal or expression to be used as the default value.
disabled
Required: No  |   Type: boolean  |   Supports runtime evaluation / JSP Expression Language: Yes

Set the disable state either with the literal "true" or "false" or with an expression.
labelStyle
Required: No  |   Type: String  |   Supports runtime evaluation / JSP Expression Language: Yes

Set the label style for each contained CheckBoxOption.
labelStyleClass
Required: No  |   Type: String  |   Supports runtime evaluation / JSP Expression Language: Yes

Set the label style class for each contained CheckBoxOption.
optionsDataSource
Required: No  |   Type: Object  |   Supports runtime evaluation / JSP Expression Language: Yes

Sets the options datasource value (an expression).
orientation
Required: No  |   Type: String  |   Supports runtime evaluation / JSP Expression Language: Yes

Set the orientation of the resulting options group.
repeater
Required: No  |   Type: boolean  |   Supports runtime evaluation / JSP Expression Language: Yes

Set whether repeating of contained options is on.
style
Required: No  |   Type: String  |   Supports runtime evaluation / JSP Expression Language: Yes

Specifies style information for the current element.
styleClass
Required: No  |   Type: String  |   Supports runtime evaluation / JSP Expression Language: Yes

The style class (a style sheet selector).

Example

In this sample, the <netui:radioButtonGroup> submits data to the Form Bean field preferredColors.

    <netui:radioButtonGroup
            dataSource="actionForm.preferredColors"
            optionsDataSource="${pageFlow.colors}" />
The optionsDataSource attribute points to a get method for a String[] on the Controller file:
    String[] colors = new String[] {"Red", "Blue", "Green", "Yellow", "White", "Black"};

    public String[] getColors()
    {
        return colors;
    }
This automatically renders the appropriate set of radionbutton options:
    <input type="radio" name="wlw-radio_button_group_key:{actionForm.preferredColors}" value="Red">Red</input>
    <input type="radio" name="wlw-radio_button_group_key:{actionForm.preferredColors}" value="Blue">Blue</input>
    <input type="radio" name="wlw-radio_button_group_key:{actionForm.preferredColors}" value="Green">Green</input>
    <input type="radio" name="wlw-radio_button_group_key:{actionForm.preferredColors}" value="Yellow">Yellow</input>
    <input type="radio" name="wlw-radio_button_group_key:{actionForm.preferredColors}" value="White">White</input>
    <input type="radio" name="wlw-radio_button_group_key:{actionForm.preferredColors}" value="Black">Black</input>


Tag Information
Tag Classorg.apache.beehive.netui.tags.html.RadioButtonGroup
TagExtraInfo ClassNone
Body ContentJSP
Display NameNone