Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSTL create a new row every 5th fieldset in a loop

Tags:

html

jsp

jstl

Hello I am currently iterating and displaying a list of fieldsets in a table. For the sake of trying to make the layout somewhat decent. I want to create a new row every time the loop gets to the 5th fieldSet. Thanks

JSP:

<div class="det" id="displayFields">
    <table class="det">
        <tr>
            <td>
                <c:forEach items="${detFieldMap}" var="detFieldEntry">     
                    <fieldset class="det">         
                        <legend>${detFieldEntry.key}</legend>  
                        <c:forEach items="${detFieldEntry.value}" var="detBean">    
                            <input type="checkbox" name="fieldNames" value="${detBean.fieldName}" <c:if test="${preselectionMap[detBean.fieldName]}">checked="checked"</c:if>>${detBean.displayName}</input>          
                            </br>    
                        </c:forEach> 
                    </fieldset> 
                </c:forEach>
            </td>
        </tr>
    </table>
</div>
like image 853
Doc Holiday Avatar asked Oct 09 '22 13:10

Doc Holiday


1 Answers

This worked:

<div class="det" id="displayFields">
    <table class="det">
        <tr>
            <td>
                <c:forEach items="${detFieldMap}" var="detFieldEntry" varStatus="loop">
                    <c:if test="${not loop.first and loop.index % 5 == 0}"> 
                        </td>
                            </tr>
                        <tr>
                            <td>
                    </c:if>
                    <fieldset class="det">         
                        <legend>${detFieldEntry.key}</legend>  
                        <c:forEach items="${detFieldEntry.value}" var="detBean">    
                            <input type="checkbox" name="fieldNames" value="${detBean.fieldName}" <c:if test="${preselectionMap[detBean.fieldName]}">checked="checked"</c:if>>${detBean.displayName}</input>            
                            </br>    
                        </c:forEach> 
                    </fieldset>
                </c:forEach>
            </td>
        </tr>
    </table>
</div>
like image 142
Doc Holiday Avatar answered Oct 12 '22 10:10

Doc Holiday