Results 1 to 3 of 3

Thread: Dynamic collections in forms

  1. #1
    Join Date
    Apr 2005
    Location
    Stockholm, Sweden
    Posts
    1

    Default Dynamic collections in forms

    Hi everyone and thanks for a very informative board

    Being relatively new with Spring I've run into a problem that I so far have not been able to solve. I'm building a FormWizard that will stretch over several jsp-pages, and some of the data entered in one page of the wizard will dynamically create objects that will need to be completed with information in the next page of the wizard.

    The problem I'm having is to iterate over the dynamically created collection of objects, and properly bind them using the spring tag. The following piece of code is how it looks currently:

    <c:forEach var="division" items="${leagueForm.league.divisions}">
    <tr>
    <td>
    <spring:bind path="division.name">
    <input type="text" name="<c:out value="${status.expression}"/>" value="<c:out value="${status.value}"/>"/>
    </spring:bind>
    </td>
    </tr>
    </c:forEach>

    The league object in the form contains a collection of division objects, and each division object has a simple get/setName method. Just printing the contents of each division object without using Spring works fine, but the binding process is beyond me. Does anyone know how to perform this type of binding on objects in a collection, where the amount of objects vary?

    Any information or references to other sources would be very appreciated!

    Cheers,
    Mathias

  2. #2
    Join Date
    Oct 2004
    Location
    Rotterdam, Netherlands
    Posts
    90

  3. #3
    Join Date
    Oct 2004
    Location
    Rotterdam, Netherlands
    Posts
    90

    Default

    You need to do something like this:

    Code:
    <c&#58;forEach var = "division" items = "$&#123;leagueForm.league.divisions&#125;" varStatus = "loopStatus">
    
      <spring&#58;bind path="leagueForm.league.divisions&#91;$&#123;loopStatus.index&#125;&#93;.name">
        <input name="<c&#58;out value="$&#123;status.expression&#125;"/>" value="<c&#58;out value="$&#123;status.value&#125;"/>" type="text" size="40" />
      </spring&#58;bind> 
    
    ....
    
    </c&#58;forEach>

Similar Threads

  1. Replies: 3
    Last Post: Aug 30th, 2005, 03:58 AM
  2. Unclosed Hibernate Connection
    By jvargas in forum Data
    Replies: 4
    Last Post: Mar 28th, 2005, 01:24 PM
  3. Replies: 1
    Last Post: Feb 25th, 2005, 07:12 AM
  4. Forms and nested properties
    By DaGGeRRz in forum Swing
    Replies: 0
    Last Post: Feb 23rd, 2005, 08:59 AM
  5. binding dynamic forms
    By klb in forum Web
    Replies: 5
    Last Post: Nov 18th, 2004, 04:22 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
  •