On Wed, 25 Apr 2012 08:47:37 -0300, trsvax <trs...@gmail.com> wrote:
I would say this is more of style preference than anything else. It can
be made to work in many ways.
Agreed. :)
My personal style is to use the URL for state and not the session.
Generally
I only use the session to store a non changing user object. If you start
there it dictates many of the decisions that follow. I believe this makes
the site more scalable, bookmarkable and reliable (testable).
Agreed. :)
As far as code reuse at first I had some of the same feelings.
Create/Edit seem like the same and the only real difference is the
onSuccess() method.
I don't think so. Just use Hibernate's Session.merge() or JPA's
EntityManager.merge() methods and you have a method that handles both
updates and inserts. ;)
However Tapestry/Hibernate/Beaneditform is so efficient at this task the
only code is in the onSuccess() method. In fact if you look at my example
the only code (1 line) that does anything is in the onSuccess() method of
the create page so trying to combine the two just makes for more code not
less.
I'm really not following you here. It contradicts what you just said above.
I've found if I follow this simple set of rules everything just fails
into place.
Fails or falls? :P
1. Never use @Persist
There are some scenarios in which you'll need to use @Persist, but I agree
that is something to be avoided when there's some other option.
2. Never use onActivate with a parameter
Why not? What about onActivate(EventContext context)? It's always invoked,
no matter how many activation context values is passed, and you have
TypeCoercer-backed coercions for free.
5. Never use inheritance for code reuse use Plastic or a service.
There are some scenarios in which using inheritance is a good idea, but I
agree that is something to be avoided when there's some other option.
6. Always use BeanEditForm
I never use BeanEditForm, but I do use BeanEditor a lot. :)
--
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