dmosses
Oct 11th, 2005, 06:24 AM
Ok,
I have a simple table, generated dynamically from a collection of user details. Each row corresponds to a user, with a tick box to allow user to be selected. This works fine if I use check boxes, and binds correctly etc.
I'd like to change the implementation slightly to allow only a single user to be selected using radio buttons in a button group. I use...
<c:choose>
<c:when test="${fn:length(users.userList) != '0'}">
<form method="post">
<table>
<tr>
<th><fmt:message key="form.select" /></th>
<th><fmt:message key="user.username" /></th>
<th><fmt:message key="user.firstname" /></th>
<th><fmt:message key="user.surname" /></th>
</tr>
<c:forEach items="${users.userList}" var="user" varStatus="counter">
<tr>
<spring:bind path="users.userList[${counter.index}].selected" >
<td>
<input type="radio"
<c:if test="${status.value}">
checked="checked"
</c:if>
name="${status.expression}" />
</td>
</spring:bind>
<td><c:out value="${user.username}" /></td>
<td><c:out value="${user.firstName}" /></td>
<td><c:out value="${user.surname}" /></td>
</tr>
</c:forEach>
</table>
<input type="submit" value="<fmt:message key="modifyuser.submit" />" align="center" />
<input type="reset" value="<fmt:message key="modifyuser.reset" />" align="center" />
</form>
</c:when>
<c:otherwise>
<fmt:message key="selectuser.nousers" />
</c:otherwise>
</c:choose>
My problem is that this requires the 'name' attribute of each button in the group to be the same. But name="${status.expression}" generates
userList[0].selected
userList[1].selected
etc.
breaking the selection group.
Any ideas of how to get around this?
Thanks in advance.
David.
I have a simple table, generated dynamically from a collection of user details. Each row corresponds to a user, with a tick box to allow user to be selected. This works fine if I use check boxes, and binds correctly etc.
I'd like to change the implementation slightly to allow only a single user to be selected using radio buttons in a button group. I use...
<c:choose>
<c:when test="${fn:length(users.userList) != '0'}">
<form method="post">
<table>
<tr>
<th><fmt:message key="form.select" /></th>
<th><fmt:message key="user.username" /></th>
<th><fmt:message key="user.firstname" /></th>
<th><fmt:message key="user.surname" /></th>
</tr>
<c:forEach items="${users.userList}" var="user" varStatus="counter">
<tr>
<spring:bind path="users.userList[${counter.index}].selected" >
<td>
<input type="radio"
<c:if test="${status.value}">
checked="checked"
</c:if>
name="${status.expression}" />
</td>
</spring:bind>
<td><c:out value="${user.username}" /></td>
<td><c:out value="${user.firstName}" /></td>
<td><c:out value="${user.surname}" /></td>
</tr>
</c:forEach>
</table>
<input type="submit" value="<fmt:message key="modifyuser.submit" />" align="center" />
<input type="reset" value="<fmt:message key="modifyuser.reset" />" align="center" />
</form>
</c:when>
<c:otherwise>
<fmt:message key="selectuser.nousers" />
</c:otherwise>
</c:choose>
My problem is that this requires the 'name' attribute of each button in the group to be the same. But name="${status.expression}" generates
userList[0].selected
userList[1].selected
etc.
breaking the selection group.
Any ideas of how to get around this?
Thanks in advance.
David.