[jboss-user] [JBoss Seam] - Nested property best practice

shea.phillips do-not-reply at jboss.com
Mon Jan 15 14:45:15 EST 2007


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.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4001891#4001891

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4001891



More information about the jboss-user mailing list