Hi,
I have successfully use String as type for property of checkbox.
It works exactly the way I expected. That is it's initial value is null
and when the checkbox is checked, it will have the value of "on",
which is the default of <html:checkbox> and the html input element
will now have one more attribute called checked="checked".
Hope this helps,
----- Original Message -----
From: "David M. Karr" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 02, 2002 1:25 PM
Subject: Re: Array of checkboxes in JSP -> props in bean
> >>>>> "Shengmeng" == Shengmeng Liu <[EMAIL PROTECTED]> writes:
>
> Shengmeng> Hi,
> Shengmeng> I agree with you that the property attribute for form element is
>"overloaded" to
> Shengmeng> have two meanings. It determines both:
>
> Shengmeng> 1)which getter method will be invoked on the form bean to obtain its
>initial value;
>
> Shengmeng> 2)which setter method will be invoked on the form bean (or the name
>of the request
> Shengmeng> parameter will be used for this element) to store its current value.
>
> Shengmeng> Well, I aslo feel that handling situations where multiple checkboxes
>share the same
> Shengmeng> name is quite confusing and complex in Struts, as the form-bean
>property refers to
> Shengmeng> a SINGLE data row, but the request parameter can have an ARRAY of
>values.
>
> Shengmeng> It seems to me that one straightforward workaround for this is to
>avoid multiple
> Shengmeng> checkboxes sharing the same name, by using different names for all
>those fields.
> Shengmeng> Such as:
> Shengmeng> group_check1="on"&group_check2="on"
> Shengmeng> where value can only be "on" and parameter name now indicates its
>real value.
>
> And how do you vary the property names when you're populating the components
> from a bean collection in an "iterate" loop?
>
> It seems like "html:multibox" would be applicable here, but I can't see from
> the documentation exactly how it is used.
>
> The situation seems to be the same with "html:radio".
>
> Ideally, when I have a set of radio buttons, and I'm using "logic:iterate" to
> iterate over them, I would want the "name" of the component to reflect the
> "choice name" I'm making, and the value should be the "choice value", which is
> NOT "on", "off", "true", or "false". I would need an attribute of my bean to
> indicate whether the radio button is initially on or not. One point of
> confusion is that the documentation for "html:checkbox" mentions that
> "property" needs to be a boolean, but the doc for "html:radio" doesn't mention
> this. I would assume it also needs to be a boolean, but I'm not certain.
>
> When this form is submitted, I would want the request parameter to be the same
> as my "choice name", and the value to be my "choice value".
>
> For instance, if I have a page to allow a user to select a "drink size" of
> "small", "medium", or "large", I would use a collection of "SizeChoice" beans,
> each of which has fields like this:
>
> String sizeId;
> String sizeDisplay;
> boolean enabled;
>
> So, I would want the button to be ON if "enabled" is true, but I want the
> submitted request parameter name to be "drinkSize" and a value of "medium" (or
> "small" or "large").
>
> However, it appears that I can't do anything like this with "html:radio". By
> specifying the "property" value of "enabled", that sets the name of the request
> parameter to "enabled". The resulting value will need to be a boolean string,
> like "on" or "true". If I have more than one radio button in the group, then
> they'll all have the same name.
>
> I would assume I'm trying to use this in the wrong way. I would appreciate
> some guidance and examples on the proper way to use this component. I can't
> seem to find good examples using radio buttons or checkboxes.
>
> --
> ===================================================================
> David M. Karr ; Best Consulting
> [EMAIL PROTECTED] ; Java/Unix/XML/C++/X ; BrainBench CJ12P (#12004)
>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>