netui:checkBoxGroup Tag

<netui:checkBoxGroup> Tag

Handles data binding for a collection of <netui:checkBoxOption> tags.

Syntax

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

Description

Handles data binding for a collection of <netui:checkBoxOption> tags.

Submitting Data

The <netui:checkBoxGroup> submits data in the form of a String[] object. For example, if the <netui:checkBoxGroup> submits data to a Form Bean field...

        <netui:checkBoxGroup 
                  dataSource="{actionForm.userSelections}"
                  optionsDataSource="{pageFlow.availableSelections}" />
...then the Form Bean field must be a String[] object...
      public static class SubmitForm extends FormData
      {
          private String[] userSelections;
      
          public void setUserSelections(String[] userSelections)
          {
              this.userSelections = userSelections;
          }
      
          public String[] getUserSelections()
          {
              return this.userSelections;
          }
      }

Dynamically Defined Checkboxes

You can dynamically define a set of checkboxes by pointing the optionsDataSource attribute at a String[] object. When the <netui:checkBoxGroup> is rendered in the browser, a corresponding set of checkboxes will be genereated from the String[] object.

For example, if you define a String[] object in the Controller file...

    public String[] availableOptions = {"option1", "option2", "option3"};
...and reference this String[] from the optionDataSource attribute...
        <netui:checkBoxGroup 
                  dataSource="{actionForm.userSelections}"
                  optionsDataSource="{pageFlow.availableSelections}" />
...then the appropriate checkboxes will be rendered in the browser.
      <input type="checkbox" value="option1">option1</input>
      <input type="checkbox" value="option2">option2</input>
      <input type="checkbox" value="option3">option3</input>
For checkboxes to be rendered, either the optionsDataSource attribute must be provided (and point to a String[] object) or the <netui:checkBoxGroup> must have children <netuiCheckBoxOption> tags.

Setting Default Options

The defaultValue attribute can be used to determine which checkboxs are checked when they are first rendered in the browser. The defaultValue attribute should point to a String, if only one checkbox should appear checked, or to a String[] object, if multiple checkboxes should appear checked.

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}">

 
RequiredSupports runtime expression evaluationData bindable
YesNoRead / 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.

 
RequiredSupports runtime expression evaluationData bindable
NoNoRead / Write

disabledBoolean. If set to true, then the rendered set of check boxes will be disabled.
 
RequiredSupports runtime expression evaluationData bindable
NoNoNo

labelStyleThe style of the label for each contained <netui:checkBoxOption> tag.
 
RequiredSupports runtime expression evaluationData bindable
NoNoNo

labelStyleClassThe class of the label for each contained <netui:checkBoxOption> tag.
 
RequiredSupports runtime expression evaluationData bindable
NoNoNo

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}

 
RequiredSupports runtime expression evaluationData bindable
NoNoRead Only

styleThe style of the rendered HTML tag.
 
RequiredSupports runtime expression evaluationData bindable
NoNoNo

styleClassThe class of the rendered HTML tag.
 
RequiredSupports runtime expression evaluationData bindable
NoNoNo

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.

 
RequiredSupports runtime expression evaluationData bindable
NoYesNo

Sample

In this first sample, the <netui:checkBoxGroup> submits data to the Form Bean field preferredColors.
        <netui:checkBoxGroup 
                  dataSource="{actionForm.preferredColors}"
                  optionsDataSource="{pageFlow.colors}" />
The optionsDataSource attribute points to a String[] on the Controller file:
        colors = new String[] {"Red", "Blue", "Green", "Yellow", "White", "Black"};
This automatically renders the appropriate set of checkbox options within the <checkBoxGroup>:
        <input type="checkbox" value="Red">Red</input>
        <input type="checkbox" value="Blue">Blue</input>
        <input type="checkbox" value="Green">Green</input>
        <input type="checkbox" value="Yellow">Yellow</input>
        <input type="checkbox" value="White">White</input>
        <input type="checkbox" value="Black">Black</input>
The defaultValue attribute may point to a String or a String[].
        defaultValue = new String ("Blue");
        defaultValue = new String[] {"Red", "Blue"};
In either case, the appropriate checkbox options will appear checked in the browser.
        <input type="checkbox" value="Red" checked="true">Red</input>
        <input type="checkbox" value="Blue" checked="true">Blue</input>
        <input type="checkbox" value="Green">Green</input>
        <input type="checkbox" value="Yellow">Yellow</input>
        <input type="checkbox" value="White">White</input>
        <input type="checkbox" value="Black">Black</input>

Code Samples

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui/checkBoxGroup/ [BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui/checkBoxOption/

Related Topics

<netui:checkBoxGroup> Tag Sample

<netui:checkBoxOption> Tag Sample

<netui:checkBox> Tag

<netui:checkBoxOption> Tag