You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wendy Smoak <We...@asu.edu> on 2003/04/17 21:26:15 UTC

RE: DynaActionForm to manage multiple and dynamic (in number) che ckbox

> I use DynaActionForm to manage multiple and dynamic (in number) checkbox
> I declared a form.bean as java.lang.String[] and the all the dynamic
> checkbox with the same name.Actually when I submit the form Struts grabs
> only the checkbox checked.I'd like to have an array of String with a
> sequence like that : off off ..on..off...on....etc.
> Any help?

It's a fact of life (HTML?) that only successful form elements are present
in the request.  And an un-checked checkbox is not a successful form
element, so [barring client-side manipulation] you will never see it in the
request.  (So no "off" will come through for the un-checked box.)

I think that indexed properties might get you what you want, though.  Can
you post the JSP you're using to display the checkboxes?

This is something I haven't yet needed and don't know exactly how to do,
only that it is [supposed to be] possible.

This page:
http://jakarta.apache.org/struts/faqs/indexedprops.html
discusses indexed properties, but the example is of text areas, not
checkboxes.

I think what you'll end up with is a String[] with null values in the
positions of the un-checked checkboxes, and whatever "value" you supplied
for the ones that are checked.

Alternately, you could use Boolean (instead of String) and set the initial
values to 'false'.  Then you'd get a Boolean[] with true/false values.

HTH... please post some of the code you're working with, especially if you
find a solution!

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management




Re: DynaActionForm to manage multiple and dynamic (in number) che ckbox

Posted by Giovanni Di Lembo <gd...@libero.it>.
how can I set initial value to false of the boolean array in
struts-config?

----- Original Message -----
From: "Wendy Smoak" <We...@asu.edu>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Thursday, April 17, 2003 9:26 PM
Subject: RE: DynaActionForm to manage multiple and dynamic (in number)
che ckbox


> > I use DynaActionForm to manage multiple and dynamic (in number)
checkbox
> > I declared a form.bean as java.lang.String[] and the all the dynamic
> > checkbox with the same name.Actually when I submit the form Struts
grabs
> > only the checkbox checked.I'd like to have an array of String with a
> > sequence like that : off off ..on..off...on....etc.
> > Any help?
>
> It's a fact of life (HTML?) that only successful form elements are
present
> in the request.  And an un-checked checkbox is not a successful form
> element, so [barring client-side manipulation] you will never see it
in the
> request.  (So no "off" will come through for the un-checked box.)
>
> I think that indexed properties might get you what you want, though.
Can
> you post the JSP you're using to display the checkboxes?
>
> This is something I haven't yet needed and don't know exactly how to
do,
> only that it is [supposed to be] possible.
>
> This page:
> http://jakarta.apache.org/struts/faqs/indexedprops.html
> discusses indexed properties, but the example is of text areas, not
> checkboxes.
>
> I think what you'll end up with is a String[] with null values in the
> positions of the un-checked checkboxes, and whatever "value" you
supplied
> for the ones that are checked.
>
> Alternately, you could use Boolean (instead of String) and set the
initial
> values to 'false'.  Then you'd get a Boolean[] with true/false values.
>
> HTH... please post some of the code you're working with, especially if
you
> find a solution!
>
> --
> Wendy Smoak
> Applications Systems Analyst, Sr.
> Arizona State University PA Information Resources Management
>
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org