Java Reference
In-Depth Information
A Bit More About How Checkboxes Work
In Stripes you can use checkboxes with different types of prop-
erties in the action bean: with an individual property, a
Collec-
tion
, or a
Map
.
• With an individual property:
<s:checkbox name="property" value="value1"/>
T property;
If the checkbox is checked,
property
is set to
value1
with
the usual type conversion to the type
T
. If the checkbox
is unchecked,
property
is set to its default value:
null
for
Object
,
false
for
boolean
,
0
for
int
, and so on.
• With a
Collection
property:
<s:checkbox name="property" value="value1"/>
<s:checkbox name="property" value="value2"/>
...
<s:checkbox name="property" value="valueN"/>
Collection<T> property;
For each checked checkbox, the corresponding value
(
value1
,
value2
, . . . ) is added to the
property
collection.
Again, values are converted to the type
T
.
If no checkbox is checked,
property
is set to
null
.
• With a
Map
property:
<s:checkbox name="property.key1" value="value1"/>
<s:checkbox name="property.key2" value="value2"/>
...
<s:checkbox name="property.keyN" value="valueN"/>
Map<K,V> property;
If at least one checkbox is checked, the
property
map
contains every key:
key1
,
key2
, . . . ,
keyN
. For each key,
the value is the corresponding
value1
,
value2
, and so on,
if the checkbox is checked or is
null
if the checkbox is
unchecked.
Type conversion occurs for converting both keys to
K
and
values to
V
.
No matter how you use checkboxes, the
value=
attribute of the
<s:checkbox> tag is optional. If omitted, the default value is
true
.
Search WWH ::
Custom Search