Sure, that's how I would generally get an object... just pass the id
around and get it again. In my particular example, that didn't work. The
object itself doesn't exist in the database per se and we needed an easy
way to transport the data around. The datasqueezer really shines here.
What's it's written and registered Tapestry just knows what to do--just
pass it as a parameter and it gets squeezed automatically. Love it!
Jamie
Andrus Adamchik wrote:
>Hi Jamie,
>
>
>
>>One thing Richard added was to put the squeeze() code into the object
>>itself so only one object had to be modified as we developed. He made a
>>constructor that takes the sqeezed object and converts it back into the
>>unsqueezed object.
>>
>>
>
>Cayenne works on the assumption that each object is uniqie within
>DataContext (a very nice feature that ensures object graph consistency).
>As a result the solution with constructor will not work for persistent
>objects, as deserialization must be able to return an object that is
>already in memory (not necessarily create a new one every time). So I am
>looking in the direction of "readResolve()" method supported by Java
>serialization mechanism
>(http://java.sun.com/j2se/1.4.2/docs/api/java/io/Serializable.html). It
>allows to substitute deserialized object with another one. This of course
>will have to rely on a thread-bound DataContext. I need maybe a day or so
>to implement (and document) a consistent generic approach applicable to
>Tapestry. I hope this day will come soon as there is a lot of demand ;-)
>
>But.... The reason I haven't done this yet, is that it is very easy to
>build links to DataObjects as it is (see "blog-tapesry" example in
>cayenne-examples download):
>
>// put this in a DataObject subclass, and then use "id" as a link parameter:
> public int getId() {
> return DataObjectUtils.intPKForObject(this);
> }
>
>// put this in the page processing the link:
> public void activateExternalPage(Object[] parameters, IRequestCycle
>cycle) {
> Blog currentBlog = null;
> if (parameters != null && parameters.length > 0) {
> currentBlog = (Blog) DataObjectUtils.objectForPK(
> getDataContext(),
> Blog.class,
> parameters[0]);
> }
> }
>
>Andrus
>
>
>
>
>
This archive was generated by hypermail 2.0.0 : Thu Mar 31 2005 - 18:49:01 EST