So I have an object and I want to add a bunch of sub-objects to it (an undetermined number– the user just keeps saying “add one more”). (ie I have an iterator and I’d like to fill it with objects).
The project is struts2 so I’ve got a JSP which sends a form to an action class, which instatiates some objects and saves them to a database. Now I need to also instatiate and save an arbitrary number of objects. I can’t just use an iterator because I don’t know how many objects are going to be involved, and I’m having trouble getting an individual object from a Struts2 form and into the iterator.
Any ideas on a good way to do this, preferrably without java in my jsps?
Thanks!
It sounds like you need an ‘Add one more action’ which the user calls repeatedly with the details of the sub object. Then when you’ve added all your sub objects you call a different action which saves the Parent and child Collection of sub objects to the database.