Gotcha. Thx for all the help guys. One more situation:
Let's say our game entity can contain an *optional *address. Because the
address data may be used in other contexts we keep that information in a
separate entity/table:

@Entity
public class Game {
        @Id
        @Validate("required")
        public String gameID;

        @ManyToOne
        @NonVisual
        public User gameOwner;
        
        public String gameType;
*
        @OneToOne
        public Address address;*
}

/**************/
@Entity
public class Address {
    @Id
    @NonVisual
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Long id = (long)0;
    
        private String address1;
        
        private String address2;
        
        private String city;
        
        private String state;
        
        private String country;
        
        private String zipcode;

        /**
         * @return the id
         */
        public Long getId() {
                return id;
        }

        /**
         * @param id the id to set
         */
        public void setId(Long id) {
                //Once id is set, that's it!
                if(id>0) return;
                
                this.id = id;
        }
...
        public Address() {
        }
        
}

Now when a user goes to create a game, I would want them to see the fields
for the game data and the optional address fields. If no address data is
submitted then the game does not keep a reference to address data otherwise
it creates an address record.

When I use the <t:beaneditform object="game"/> in this scenario I will only
get the fields specific to game. Is it best practice here to create a custom
form that contains game and address fields or is there a better way? If not,
is there some way to automatically bind the fields from the form to the
respective entity properties?

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Understanding-Entities-with-Entities-in-the-Tapestry-Framework-tp5579217p5587322.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to