Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding pojo as form backing object with Set of other pojos with dynamic creation
    text
    copied!<p>I am using Spring 3.0.2, Hibernate 3,5 (not sure) and JSP to create a web application. While creating a simple form (backed by pojo with simple attributes), everything works just fine. However now I am trying to create form like this:<br/></p> <ul><li>backing pojo is Person with let's say String name attribute</li> <li>Person has Set contacts attribute</li> <li>Contact pojo has String city and String phoneNumber attributes</li> </ul> <p>I would like to be able to edit all the information on one page which means editing name, specifying city and phoneNumber.<br/> Can any one of you direct me to the right path on how to bind nested collections?<br/> Should I create ModelAttribute("contactsForPerson") in the controller and pass it to the jsp and use this in my jsp?</p> <pre><code>&lt;form:form method="post" modelAttribute="person" &gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;form:hidden path="idPerson"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Name&lt;/td&gt; &lt;td&gt;&lt;form:input path="name" value="${person.name}"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;c:forEach items="${contactsForPerson}" var="a"&gt; &lt;tr&gt; &lt;td&gt;City&lt;/td&gt; &lt;td&gt;&lt;form:input path="contacts.city" value="${a.city}"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Phone Number&lt;/td&gt; &lt;td&gt;&lt;form:input path="contacts.phoneNumber" value="${a.phoneNumber}"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/c:forEach&gt; &lt;/table&gt; </code></pre> <p> Question itself boils down to how to specity path attribute of Person so that set of Contacts is binded :)</p> <p>Thanks in advance for your advice</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload