Checking/unchecking checkboxes based on returned database values

Viewed 631

I am trying to get a checkbox to be checked based on values returned from a database. So far I'm getting the correct "Y" or "N" values up to my controller layer, but the checkbox is not being checked/unchecked as it should. I tried the following but it doesn't work, I'm thinking that something is wrong with the test scenario.

<td  class="normalTD " width="4%" style="white-space: nowrap" align="left" >
<c:choose>
<c:when test="detail[${loop.index}].flag eq 'Y'">
    <input type="checkbox" path="detail[${loop.index}].flag" id="detail[${loop.index}].flag" checked="checked" />
</c:when>
<c:otherwise>
    <input type="checkbox" path="detail[${loop.index}].flag" id="detail[${loop.index}].flag" checked="" />
</c:otherwise>
</c:choose>
</td>

Loop before checkbox:

<c:set var="detail" value="${commandObj.detail}" scope="page" />
    <c:if test="${!empty commandObj.detail}">
        <c:forEach items="${commandObj.detail}" var="detail" varStatus="loop">
            <c:if test="${!empty detail.cd}">
1 Answers
Related