On Mon, 21 Feb 2011 14:05:25 -0300, robnangle <robnan...@gmail.com> wrote:
I am not using tapestry-hibernate, is there any examples out there
because the few I have came across seem to be very complex?
There are some examples out there that I consider the wrong approach,
specifically implementing both ValueEncoder and SelectModel in the same
class.
Suppose you have a class User and a DAO for it named UserDAO (not tested):
class UserValueEncoder<User>() {
final private UserDAO dao;
public UserValueEncoder(UserDAO dao) {
this.dao = dao;
}
public String toClient(User user) {
return user.getLogin();
}
public User toValue(String clientValue) {
return dao.findByLogin(clientValue);
}
}
@Property
private User user;
<select t:type="Select" value="user" .../>
You could use any logic for that. For example, you could use the user id
instead of login and your application would behave exactly the same.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org