2 Replies Latest reply on Jan 15, 2007 8:42 PM by Gavin King

    Nested property best practice

    Shea Phillips Newbie

      Hello,

      I am experimenting with Seam's new Application Framework stuff (EnitityHome, etc.) in order to write as little code as possible for doing trivial things (CRUD, in particular).

      The question I have relates to editing a parent object and attributes of child objects from within the same form. Specifically, I have a "Person" class that contains an instance of an "EmailAddress" class as a property. The EmailAddress has a "locationAddress" propety that contains the actual address String. The EmailAddress will initially be null (which is a legitimate case). I want to use a single "Person" editing form for capturing the Person's simple propeties and a simple text input in that for for the email address. The problem I am looking for advice on is how to deal with intelligently instantiating an EmailAddress when a user enters a string. Since the the emailAddress property of the Person instance is initially null, JSF binding fails when a user enters an email address in the form. (the binding expression for the email inputText is #{myperson.emailAddress.locationAddress}).

      Does anyone have any clean solutions for automagically instantiating an EmailAddress instance and binding it to the Person's emailAddress property prior to binding the provided emailAddress string to it?

      I realize I could add properties and logic to my Home class to deal with this, or provide delegate transient properties on my Person class, but I am hoping to avoid this, since this is a pretty common situation and I would like as clean a solution as possible.

      This is not specific to Seam, or the App Framework, or JSF for that matter, but I am hoping someone has some thoughts on it....

      Thanks,

      Shea.