Announcement Announcement Module
Collapse
No announcement yet.
[Complex Form] binding of nested models Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Complex Form] binding of nested models

    Hi all,

    for first sorry for my english.

    I've a complex Form where I need to bind nested objects into the master model attribute.

    I mean: I've a Form to handle a "Contract" data, in this Form I can add multiple "Contract conditions" and each "Condition" has multiple "Condition details".

    So a "Contract" has a property with a collection of "conditions" and each "condition" has a a property with a collection of "details".

    The tables relationship and corresponding hierarchy of java classes are corrects but I don't know how to bind nested objects into the "Contract" ModelAttribute.

    I don't know ho to us PropertyEditors to handle this situation.

    If I have an input form link this:

    Code:
    <input type="text" name="conditions[0].fromDate" />
    Property Editor for "Condition" objects is not triggered.

    If I write only:
    Code:
    <input type="text" name="conditions[0]" />
    It works but I need to set each property of that condition.

    I need to create N conditions:
    Code:
    <input type="text" name="conditions[0].fromDate" />
    <input type="text" name="conditions[0].toDate" />
    <input type="text" name="conditions[0].description" />
    
    <input type="text" name="conditions[1].fromDate" />
    <input type="text" name="conditions[1].toDate" />
    <input type="text" name="conditions[1].description" />
    
    ....
    How can I catch a "conditions[n].property" in POST data and bind it into the Model Attribute?

    Thanks a lot.
Working...
X