I use Spring MVC 3.0 and JSP. I have an object:
public class ObjectWrapper {
private List<SomeTO> someTOs;
}
Class SomeTO contains fields like name and id. How can I create a form on which an user can dynamically add to list of SomeTO? I googled it and found something about spring:bind, but it’s unclear for me.
In the form backing method, set the list to a LazyList which is part of the apache commons collection library.
Then on your form, when you send the data to the server you can do it like this
And if your using
then you can simply go.
Before posting the data to the server, to make pruning easier, set the number of elements in the collection. So if the user added 5 TOs, then send that length value in the form post.
ON the server now, you must prune the list before you save it. Here is the function for pruning
Here is the use of the prune function in the on submit (before save)