
Untitled
By: a guest on
Jul 31st, 2012 | syntax:
None | size: 0.96 KB | hits: 14 | expires: Never
form:checkbox inside repeated section
class Filter {
private String name;
private boolean enabled;
// More fields, plus the obvious setters & getters.
}
class MyCommand { // in the model as "myCommand"
List<Filter> filters;
// Lots more, plus the obvious setters & getters.
}
<form:form method="post">
<c:forEach var="filter" varStatus="stat" items="${myCommand.filters} >
<!-- wrapping that makes accordion panels not shown -->
<form:checkbox path="filter.enabled" id="${filter.name}_enabled"/>
<label for="${filter.name}_enabled">${filter.name}</label>
</c:forEach>
</form:form>
<input type="checkbox" ${filter.enabled ? "checked='checked'" : "" }
name="filters[${stat.index}].enabled" />
<input type="checkbox" ${filter.enabled ? "checked='checked'" : "" }
onclick="$('#FilterHidden_${stat.index}').val(this.checked)" />
<input type="hidden" id="FilterHidden_${stat.index}"
name="filters[${stat.index}].enabled" />