views:

30

answers:

1

Hi all,

On a view I have 1 form and 1 list with form - both are within single tag. List is bound to ArrayList of beans and related form is used to add objects to that list. There are 2 actions on page: adding to list and saving all data.

Now the problem is that if user clicks save then whole form is submitted, bound and validated. The list adding form fails validation because it is probably empty at that point. If I do not validate that form then Spring would still bind that element to list[list.size()] and because all fields are empty for that bean hibernate fails to save it.

I need any ideas or practices how this kind of things are solved. How save would bind and validate part of the form and addNewItem would bind and validate another part.

A: 

I would just have a single form, with some javascript that adds items to the list. Submit the form once, and have all your validation done at the same time.

You'll need to use something like Spring's AutoPopulatingList for this technique to work.

Daniel Alexiuc