Wednesday, August 13, 2014

Spring - multiple check boxes check

This Post explain you how to auto check the check box fields in Spring's at the time of loading page:


In controller you need to set the selected categories:

clientLinkAbuseTypesForm.setSelectedCategories(new Long{10,11..etc});

In Jsp page:
<c:forEach items="${displayGroup.value }" var="cateogryRec" varStatus="rec" >
<form:checkbox path="selectedCategories" value="${cateogryRec.key }" /><span id="Name"><c:out value="${cateogryRec.value }"/></span></td>


Here selectedCategories is the  Long[] selectedCategories of form ; Which contains the check box values which to make checked=true.

The spring will take care of checked=true .

No comments: