My requirement is to do a CREATE operation by providing the user with a form in a JSP with input fields from two entities (e.g. UserDetails and EmploymentDetails)
What is the most effective way to update two forms in a single jsp using a single submit?
One approach I know of is to combine the two entities into a single wrapper-class and then send that object as Model. Is that the only solution?
Kindly guide.
Could try mapping each object to different model attribute:
In the form, these should be bound to different prefixes, eg:
It's a common practice to put any number of objects in a wrapper class and use this one to submit data with a single form. Additionally, you can use JSR-303 validation in any of objects:
your form:
and your controller:
Another approach is to save objects via JSON, but I think is overkill and overcomplicated in this case.