You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mats Andersson <ma...@ronsoft.se> on 2009/09/03 14:58:20 UTC
Using object or id in Context
Why are most examples written as context="myObject.id"?
Should not the best practice be to use the object directly? This way the
handler method will be more type safe. Do you know of any good
best-practices page for issues like this one?
/Tapestry learner
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using object or id in Context
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 03 Sep 2009 09:58:20 -0300, Mats Andersson
<ma...@ronsoft.se> escreveu:
> Why are most examples written as context="myObject.id"?
> Should not the best practice be to use the object directly? This way the
> handler method will be more type safe. Do you know of any good
> best-practices page for issues like this one?
Because the object would be coerced to a String. Then you would need to
get this String and get the original object back.
In Tapestry CRUD, an open source package I'm developing, there's an
ActivationContextEncoder. It's similar to a ValueEncoder, but used
specifically for activation context values. Then I have some components
(ActivationContextPageLink, ActivationContextActionLink) that receives an
Object and uses the corresponding ActivationContextEncoder to get the
object's activation context value.
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org