struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Musachy Barroso <>
Subject Re: s:checkbox inside a s:iterator and values in a Integer[]
Date Sun, 12 Jul 2009 23:37:53 GMT
you need to specify the "value" attribute, which is the one that will
make it checked or not, for example, assume "possibleValues" is the
list of possible values, and "selectedValues" is the list of currently
selected values, and both lists contain objects that have an int "id"
field (same type of objects):

<s:iterator value="%{possibleValues}">
<s:checkbox name="categoryId" fieldValue="%{id}"
value="%{#selectedValues.contains(top)}" />


2009/7/12 Ignacio de Córdoba <>:
> Hello,
> I've browsed nabble, google, ... but can't find a simple example on how to
> do something very simple.
> I need to iterate through, let's say, a picture category list, showing each
> category as a s:checkbox. The picture belongs to some of these categories
> (and user can changed that, or course, thanks to the checkboxes), so some of
> the checkboxes must be pre-checked. Which of them are checked is shown in a
> Integer[] (could be String[] if necesary, no problem). I guessed the right
> way to do it is using a String or Integer array as checked values will be
> sent to the struts2 action through that same property.
> Is it that difficult to use s:checkbox for this? I know how to do it using
> s:checkboxlist but can't here as I need special format in the iteration.
> For some reason the following:
> <s:iterator value="categoryTree">
> <s:checkbox labelposition="right" name="categoryId" fieldValue="%{id}"
> label="%{name}"/>
> </s:iterator>
> (categoryId is a Integer[] having which id values should be checked but all
> checkboxes appear as checked)
> For some reason I've found more people with this same problem but they got
> no answers. Thanks for any example or ideas if I must change the way
> pre-checked data is got from the action.
> Ignacio
> --
> View this message in context:
> Sent from the Struts - User mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

"Hey you! Would you help me to carry the stone?" Pink Floyd

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message