I've probably asked this before, but the information refuses to stick
to my brain.

This pattern comes up a lot for me: I have an action bean for a form,
and part of the form is a set of radio buttons corresponding to an
enum for some modal behavior (say, an item type filter selector for a
"query" action). The default setting for the radio buttons should be
the "Any" or "Don't Care" option, which corresponds to an empty value
- a null for the enum reference in the action bean, in other words.

When I submit the form, the empty value for the "Don't Care" radio
button does what I want: the action bean gets a null enum reference,
so the query operation proceeds without including any filter for the
item type. If another radio button is selected, then the field is
correctly populated and things work fine.

The problem comes up in the initial population of the form. The "Don't
Care" radio button is given "value = ''" and "checked = 'true'"
attributes, but Stripes leaves all the radio buttons unchecked. The
action bean has no value for the enum property, but for some reason
Stripes doesn't relate that empty value to the empty value on the
default radio button.

So my question is, why is that?  It's easy enough to work around by
coding up a non-Stripes <input type='radio' ...> element, but I don't
understand what the "greater good" is from Stripes not deciding that
the null enum value should correspond to the radio button with the
empty value attribute, since that's exactly how things will be bound
in the other direction.


-- 
Turtle, turtle, on the ground,
Pink and shiny, turn around.

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to