Results 1 to 3 of 3

Thread: bind set of checkbox values

  1. #1
    Join Date
    Jun 2005
    Posts
    17

    Default bind set of checkbox values

    I have a collection of values, which I'd like the user to select some subset of. How can I show a list of checkboxes and bind the values of those checkboxes into some sort of collection which represents the user's selection?

    I know how to bind checkboxes to single bean properties. In this case, I'll need to bind to some sort of collection (any will do).

    Does spring support binding checkbox values to maps (in the same way as binding to beans)? I'm thinking something like:
    Code:
    <c&#58;forEach var="$&#123;category&#125;" items="$&#123;categories&#125;">
     <spring&#58;bind path="form.selectedCategories&#91;$&#123;category&#125;&#93;">
      <input type="hidden" name="_$&#123;status.expression&#125;" />
      <input type="checkbox" value="true" name="$&#123;status.expression&#125;" <c&#58;if test="$&#123;status.value&#125;">checked="checked"</c&#58;if> > $&#123;category&#125;
     </spring&#58;bind>
    </c&#58;forEach>

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    Last edited by robyn; May 15th, 2006 at 05:48 PM.

  3. #3
    Join Date
    Jun 2005
    Posts
    17

    Default

    Are you referring to the code provided by j2ux? If so... is there a way to index into a map (as my code shows) instead of a list?

Similar Threads

  1. MySQL DDL
    By analogueboy in forum Security
    Replies: 5
    Last Post: Aug 17th, 2007, 03:48 PM
  2. Replies: 0
    Last Post: Jul 25th, 2005, 08:48 AM
  3. Replies: 2
    Last Post: May 5th, 2005, 09:35 PM
  4. Replies: 5
    Last Post: Apr 27th, 2005, 07:04 PM
  5. How do you bind on multiple checkbox?
    By egravel in forum Web
    Replies: 2
    Last Post: Feb 25th, 2005, 07:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •