Announcement Announcement Module
Collapse
No announcement yet.
Nested properties Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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:

    Code:
    person.address.state.stateId
    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?

    Comment


    • #3
      Check out this thread.

      http://forum.springframework.org/showthread.php?t=16684

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

      Comment

      Working...
      X