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)}" />
</s:iterator>

musachy

2009/7/12 Ignacio de Córdoba <icord...@skios.es>:
>
> 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: 
> http://www.nabble.com/s%3Acheckbox-inside-a-s%3Aiterator-and-values-in-a-Integer---tp24452969p24452969.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>



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

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

Reply via email to