struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmk...@earthlink.net (David M. Karr)
Subject Proposal: Add "nameValue" and "checkedProperty" to "radio" (and "checkbox"?)
Date Wed, 02 Jan 2002 19:53:01 GMT
I've often been frustrated by some details of the "radio" and "checkbox" tags.
I have some issues with the rules for producing the "name" of the resulting
element, and for deciding whether the component should be checked.  I'd like to
get some opinions on my proposed change.

The crux of the problem is that the "property" attribute is "overloaded" for
two purposes:

 1. The name of the bean property to get the current value from.
 2. The name attribute of the HTML component.

Unfortunately, it's often desirable (IMHO) for those two values to be
different.

For instance, it seems conceivable that the bean used to populate the component
would have two fields, one being a String, representing the "option name", and
the other being a boolean, indicating whether the option is on or not.  It
would be reasonable to name the boolean field "enabled".

However, using a boolean property of "enabled" means that the resulting radio
button will have a "name" attribute of "enabled", as opposed to something akin
to the "option name".

I've modified my local copy of the Struts (1.0.1rc1) so that the "radio" tag
has two additional attributes:

  "nameValue"

If present, this will be the value of the "name" attribute in the resulting
component.  If not set, the value of the "property" attribute will be used.

  "checkedProperty"

If present, the value of this property on the named bean will be compared with
"true" to determine whether this component is "checked".  If not set, it will
compare the "value" attribute against the value of the "property" property.

I've tested this change in my environment and application, and it appears to
work.  The change is backward-compatible, because if neither of these two
attributes are set, the behavior is the same as before.

When I use these attributes, however, I'm able to use a reasonable property
name for the "checked" property, and a reasonable name for the "name" of the
HTML component.

If I follow through with a patch for this, I'd obviously have to make similar
changes in the "checkbox" and "multibox" component (although I'm not familiar
with the latter component yet).  I would assume I would also need to provide
documentation and unit test patches.  I would also make the patches against the
latest in CVS, instead of the 1.0.1rc1 source release.

What do you think?

-- 
===================================================================
David M. Karr          ; Best Consulting
dmkarr@earthlink.net   ; Java/Unix/XML/C++/X ; BrainBench CJ12P (#12004)


--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>


Mime
View raw message