Since T5 still can't predict the future (pfff!), you need to set the reference to the user yourself :) There are several ways to do this...
So, all your CreateGame page needs is the user - right? Then let's add an page activation context: @Property private Game game; private User user; onActivate(User u){ this.user = u; } void onPassivate(){ return user; } for this to work you need to provide the user as page activation context in your link to the CreateUser page: <t:pagelink page="CreateUser" context="user"/> The url will then probably look like this: /blah/createUser/1 Of course, the userId has to get into the Game object somehow. I would do that in my onSuccess() method, by simply setting the property: game.gameOwner = user; You could also instantiate the game object yourself in your onActivate method and set the property there, but then you would need to persist that object between requests (which you could do with the @Persist annotation) BTW: While the user's email might be unique for a user entity, I don't think it's a clever idea to use it as the primary key. The foreign keys would all be varchars and the real fun starts when someone want's to change its email... I strongly suggest you add a ID property: @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; Cheers :) Beat 2012/3/20 IcedDante <ultimate_ham...@yahoo.com>: > 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="hidden" name="userID" value="<%= > 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 > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org