Reputation: 648
I completely have no idea how can I force JSP to modify values in collection.
I have code like this (the most important part - I think):
<tbody>
<c:forEach items="${formObject.userList}" var="list" varStatus="cnt">
<c:set var="idx" value="${cnt.index}"/>
<tr>
<td class="moduleCode">
<c:choose>
<c:when test="${list.userType == 'OW'}"> <spring:message
code="manage-flow.user.message.ow"/>
</c:when>
<c:when test="${list.userType == 'CO'}"> <spring:message
code="manage-flow.user.message.co"/>
</c:when>
<c:when test="${list.userType == 'RE'}"> <spring:message
code="manage-flow.user.message.re"/>
</c:when>
<c:when test="${list.userType == 'JU'}"> <spring:message
code="manage-flow.user.message.ju"/>
</c:when>
</c:choose>
</td>
<td class="moduleCheckbox">
<div>
<input type="checkbox" name="s-${idx}"
<c:if test="${list.availA}">checked</c:if>
<c:if test="${!formObject.edited}">disabled</c:if> />
</div>
</td>
<td class=" moduleCheckbox">
<div>
<input type="checkbox" name="se-${idx}"
<c:if test="${list.availP}">checked</c:if>
<c:if test="${!formObject.edited}">disabled</c:if> />
</div>
</td>
<td class="moduleCheckbox">
<div>
<input type="checkbox" name="ser-${idx}"
<c:if test="${list.availC}">checked</c:if>
<c:if test="${!formObject.edited}">disabled</c:if> />
</div>
</td>
</tr>
</c:forEach>
</tbody>
some of them are already checked, and some not (I am reading from DB) and setting this up.
Now, we have situation like this. I have an unchecked checkbox and i am clicking it to check him. And after clicking save button, the formObject send is unchanged (it is exactly the same, as it comes from DB), and so I am updating row in DB with same values...
Can you help me out?
Upvotes: 1
Views: 27
Reputation: 648
Solution, which is working for me.
<tbody>
<c:forEach items="${formObject.userList}" var="list" varStatus="cnt">
<c:set var="idx" value="${cnt.index}"/>
<tr>
<td class="moduleCode">
<c:choose>
<c:when test="${list.userType == 'OW'}"> <spring:message
code="manageUser-flow.user.message.ow"/>
</c:when>
<c:when test="${list.userType == 'CO'}"> <spring:message
code="manageUser-flow.user.message.co"/>
</c:when>
<c:when test="${list.userType == 'RE'}"> <spring:message
code="manageUser-flow.user.message.re"/>
</c:when>
<c:when test="${list.userType == 'JU'}"> <spring:message
code="manageUser-flow.user.message.ju"/>
</c:when>
</c:choose>
</td>
<td class="moduleCheckbox">
<div>
<c:if test="${!formObject.edit}">
<form:checkbox path="userList[${idx}].availA"
cssClass="checkbox" value="true" disabled="true"/>
</c:if>
<c:if test="${formObject.edited}">
<form:checkbox path="userList[${idx}].availA"
cssClass="checkbox" value="true"/>
</c:if>
</div>
</td>
<td class=" moduleCheckbox">
<div>
<c:if test="${!formObject.edit}">
<form:checkbox path="userList[${idx}].availP"
cssClass="checkbox" value="true" disabled="true"/>
</c:if>
<c:if test="${formObject.edited}">
<form:checkbox path="userList[${idx}].availP"
cssClass="checkbox" value="true"/>
</c:if>
</div>
</td>
<td class="moduleCheckbox">
<div>
<c:if test="${!formObject.edit}">
<form:checkbox path="userList[${idx}].availC"
cssClass="checkbox" value="true" disabled="true"/>
</c:if>
<c:if test="${formObject.edited}">
<form:checkbox path="userList[${idx}].availC"
cssClass="checkbox" value="true"/>
</c:if>
</div>
</td>
</tr>
</c:forEach>
</tbody>
Upvotes: 1