Dynamic Forms Example

Note: Below is a table that has the expected outcomes of various configurations.

Create form backing object on submit
Use dynamically created fingers
Finger:
Finger:
Finger:
Finger:
Finger:
Expected Results
Condition Result on Submit Explanation
Create form backing object on submit
Use dynamically created fingers
Fingers Added
NullValueInNestedPathException Exception On page load, a Hand was created with five fingers; each finger was turned into a form element. When the page is submitted, no form backing object is created (a hand with five fingers), and no Hand with dynamic fingers is created. When Spring attempts to add the fingers to the hand it cannot because the form backing object has an empty ArrayList of Fingers.
Create form backing object on submit
Use dynamically created fingers
Fingers Added
Success On page load, a Hand was created with five fingers; each finger was turned into a form element. When the page is submitted, a form backing object is created (a hand with five fingers). Since no fingers were added Spring is able to overlay the five fingers from the form on to the form backing object.
Create form backing object on submit
Use dynamically created fingers
Fingers Added
IndexOutOfBoundsException Exception On page load, a Hand was created with five fingers; each finger was turned into a form element. When the page is submitted, a form backing object is created (a hand with five fingers). Spring is able to add the first five fingers successfully; it will bomb when trying to add the sixth.
Create form backing object on submit
Use dynamically created fingers
Fingers Added
Success On page load, a Hand was created with five fingers; each finger was turned into a form element. When the page is submitted, all finger elements on the page will be automatically added to the lazy-list. In this case there are still the original five fingers but any number of fingers will work.
Create form backing object on submit
Use dynamically created fingers
Fingers Added
Success On page load, a Hand was created with five fingers; each finger was turned into a form element. When the page is submitted, all finger elements on the page will be automatically added to the lazy-list. Any number of fingers will work.