Right, well I understand that. In fact that is how I would do it
traditionally in a J2EE environment but my understanding is that some of
this should be done auto-magically with the Tapestry/Hibernate combination.

So for example, let's say we have a game application where a User can start
a game and invite players. We have the User entity:

@Entity
public class User {
        public String firstName;
        
        public String lastName;
        
        @Validate("required")
        public String userID;
        
        @Id
        @Validate("required,email")
        public String email;
        
        @Validate("required")
        public String password;
        
        @NonVisual
        public boolean validated;
        
}

And making the pages/user/CreateUser.java and .tml is pretty trivial:
public class CreateUser
{

        @Property
        private User user;
        
}
//************************
<html t:type="layout" title="Create New User"
  xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";>
        <t:beaneditform object="user"/>
</html>

But what about the game class? The entity is easy:
@Entity
public class Game {

        @Id
        @Validate("required")
        public String gameID;

        @MayToOne
        public User gameOwner;
        
        public String gameType;

        public Game() {}
}

But the fact that this entity refers to a gameOwner changes things. I am
using the ManyToOne since a user can start multiple games, I think /maybe/ I
should use @NonVisual since the person creating the game doesn't specify the
gameOwner but I'm not sure.

Now what does the pages/game/CreateGame.java class look like? And the tml?
this is where I am getting lost. I need to supply the User information of
the current user as the GameOwner and I would traditionally do this with an
embedded hidden tag in a JSP:
<input type=&quot;hidden&quot; name=&quot;userID&quot; value=&quot;&lt;%=
user.getUserID() %>" />

But what is the best way to do it with Tapestry/Hibernate?

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Understanding-Entities-with-Entities-in-the-Tapestry-Framework-tp5579217p5580387.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