Back Forum Reply New

Multi checkbox... again

Hello

I want to use checkboxes for selecting in my application and find out a way to do that as the following:

=========================================
lt;c:forEach items=quot;${command.childArray}quot; var=quot;childquot; varStatus=quot;loopStatusquot;gt;    lt;spring:bind path=quot;command.childArray[${loopStatus.index}].selectedquot;gt;        lt;input type=quot;hiddenquot; name=quot;_lt;cut value=quot;${status.expression}quot;/gt;quot;gt;       lt;input type=quot;checkboxquot; name=quot;lt;cut value=quot;${status.expression}quot;/gt;quot; value=quot;truequot;lt;c:if test=quot;${status.value}quot;gt;checkedlt;/c:ifgt;/gt;    lt;/spring:bindgt;  lt;/c:forEachgt;
========================================

It can be seen that to use this way, the objects (for selecting) must be in an array (childArray). So I can have:

lt;spring:bind path=quot;command.childArray[${loopStatus.index}].selectedquot;gt;

What I have to do if it is a list - not an array ???.

I tried:

lt;spring:bind path=quot;command.objectList.get(loopStatus.index).sel  ectedquot;gt;

But it does not work

Thanks for any help
sho

having Integer[] selectedItems in your command with getter/setters and then in the JSP doing the following works.

lt;c:forEach items=quot;${items}quot; var=quot;itemquot;gt;
lt;form:checkbox path=quot;selectedItemsquot; value=quot;${item.id}quot;/gt;
lt;/c:forEachgt;

No need for indexes, etc.

This uses the Spring 2.0 form taglib.

However, my one is only 1.2.7 - it is a workgroup project - hard to change the verson of the spring
Regards


Originally Posted by gmatthewshaving Integer[] selectedItems in your command with getter/setters and then in the JSP doing the following works.

lt;c:forEach items=quot;${items}quot; var=quot;itemquot;gt;
lt;form:checkbox path=quot;selectedItemsquot; value=quot;${item.id}quot;/gt;
lt;/c:forEachgt;

No need for indexes, etc.

This uses the Spring 2.0 form taglib.

Excellent post gmatthews.
¥
Back Forum Reply New