Handles data binding for a collection of <netui:checkBoxOption> tags.
<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"] />
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 theoptionsDataSource
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.
dataSource | The 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. The 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. |
||||||
|
|||||||
|
|||||||
defaultValue | Use in <netui:checkBoxGroup>, <netui:checkBox>, <netui:radioButtonGroup>, and <netui:select> tags Sets the preselected value or values. The If the If the Use in <netui:textArea> and <netui:textBox> tags Sets the initial display text. The |
||||||
|
|||||||
|
|||||||
disabled | Boolean. If set to true , then the rendered set of check boxes will be disabled. |
||||||
|
|||||||
|
|||||||
labelStyle | The style of the label for each contained <netui:checkBoxOption> tag. | ||||||
|
|||||||
|
|||||||
labelStyleClass | The class of the label for each contained <netui:checkBoxOption> tag. | ||||||
|
|||||||
|
|||||||
optionsDataSource | The In a <netui:select> tag, the options are
rendered as a set of <netui:option> tags.
The options can be determined dynamically by pointing the
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
|
||||||
|
|||||||
|
|||||||
style | The style of the rendered HTML tag. | ||||||
|
|||||||
|
|||||||
styleClass | The class of the rendered HTML tag. | ||||||
|
|||||||
|
|||||||
tagId | String value. Sets the For example, assume that some tag's <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 <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 |
||||||
|
|||||||
|
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>
<netui:checkBoxGroup> Tag Sample