Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 31st, 2012  |  syntax: None  |  size: 0.96 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. form:checkbox inside repeated section
  2. class Filter {
  3.   private String name;
  4.   private boolean enabled;
  5.   // More fields, plus the obvious setters & getters.
  6. }
  7. class MyCommand {  // in the model as "myCommand"
  8.   List<Filter> filters;
  9.   // Lots more, plus the obvious setters & getters.
  10. }
  11.  
  12. <form:form method="post">
  13.   <c:forEach var="filter" varStatus="stat" items="${myCommand.filters} >
  14.     <!-- wrapping that makes accordion panels not shown -->
  15.     <form:checkbox path="filter.enabled" id="${filter.name}_enabled"/>
  16.     <label for="${filter.name}_enabled">${filter.name}</label>
  17.  
  18.   </c:forEach>
  19. </form:form>
  20.        
  21. <input type="checkbox"  ${filter.enabled ? "checked='checked'" : "" }
  22.     name="filters[${stat.index}].enabled" />
  23.        
  24. <input type="checkbox"  ${filter.enabled ? "checked='checked'" : "" }
  25.      onclick="$('#FilterHidden_${stat.index}').val(this.checked)" />
  26.  
  27. <input type="hidden" id="FilterHidden_${stat.index}"
  28.     name="filters[${stat.index}].enabled" />