Im using Struts2 and Hibernate, trying to create a simple form to edit an object and all its children (one-to-many).
I’ve attached an image to show what im trying to do.
Does anyone have any idea/examples of how I can do this the easiest way? I just cannot understand how to create this kind of form. I’ve looked for answers for 2 days now, without getting anywhere.
I have been able to create the simple person-form and persisting it, and I have also been able to display a list of the pets in the form, but I have not come any closer to a solution as to how to create new pets and edit them.
The easiest way is probably to use ajax; this way adding/editing a pet can be persisted immediately and the owner can be persisted when submitting the form. The other solution would be to add all the information into the request when submitting the form and figuring out in your Action class what to do; it is feasible but will require some thinking and javascript (although also for the ajax solution you will require this).