Announcement Announcement Module
No announcement yet.
Nested properties Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Nested properties

    I have a fairly simple object hierarchy. I have a Person class, each Person has an Address and each Address has a Country and a State. A Person may optionally have an Address and an Address may optionally have a Country and optionally have a State. Got it? Good.

    Now I have a form where the user can edit all properties of the Person, Address, Country and State. The State and Country properties are displayed as selects of all possible states and countries from my database. For example my state property is bound as:

    The rest of the properties are equally as strait forward, but I can provide more examples if needed.

    If I try to bind and person to the form and that person doens't have an Address or that Address doesn't have a State or Country I get a org.springframework.beans.NullValueInNestedPathExc eption. How do I work around this scenario? I also have problems when trying to bind the form elements back to the domain object, but one thing at a time.

    Thanks for any pointers.

  • #2
    My current solution, and one I'm not really happy with, is to flatten out my object graph and use that as the form backing object. Then in my controller I re-assemble the object graph.

    Anyone have a better idea?


    • #3
      Check out this thread.

      Some good solutions are noted here. I'm having the same trouble.
      Last edited by robyn; May 15th, 2006, 06:01 PM.