Re: DataObject becomes hollow when passed through a tapestry DirectLink

From: Erik Hatcher (eri..hatchersolutions.com)
Date: Thu Mar 31 2005 - 11:23:34 EST

  • Next message: Eric Schneider: "Re: DataObject becomes hollow when passed through a tapestry DirectLink"

    On Mar 31, 2005, at 9:19 AM, Robert Zeigler wrote:
    > Erik Hatcher wrote:
    >> Regarding using a rich (i.e. not a String or simple type) object as a
    >> parameter in a DirectLink - this is not really recommended in the
    >> general sense. The URL is going to be hideous and perhaps even too
    >> long
    >> for some browsers to handle.
    >>
    >> A trick within Tapestry, though, would be to use a custom DataSqueezer
    >> that serialized only the primary key and a unique prefix, and then
    >> "deserialized" by fetching again using the facility Andrus describes
    >> below. I have not tried this route - have others?
    >>
    >> Erik
    >>
    >
    > I haven't, but it's a good idea that solves the problem exactly once.
    > I just did a quick once-over of the DataSqueezer implementation...
    > there
    > are some questions still lurking in my mind about this approach.
    > 1) In order to "deserialize" the object, you're going to need access to
    > the correct DataContext from within a custom adaptor. If you store the
    > datacontext in the visit, then this could be solved by using a
    > ThreadLocal Engine approach, I suppose. Or, you could use the utilities
    > provided by andrus for binding a dc. to a thread, and getting the
    > thread
    > local dc. Correct me if I'm wrong, Erik, but, at least in tapestry
    > 3.0,
    > wouldn't you need to sublcass BaseEngine anyway to override
    > createDataSqueeezer() to return an instance that contains the custom
    > squeeze adaptor?

    I had to look up the details myself. I'm trying to migrate entirely
    into Tapestry 3.1, so I had to go back in time :) In 3.1, adaptors are
    registered with HiveMind. In 3.0, you'll do something like this in a
    BaseEngine subclass:

         public DataSqueezer createDataSqueezer() {
             DataSqueezer squeezer = new DataSqueezer(getResourceResolver(),
    new ISqueezeAdaptor[] { new CustomAdaptor()});
             return squeezer;
         }

    Yeah, getting the right context in the squeezer is the trick and it
    seems like ThreadLocal is a great trick.

    I'm going to start using Cayenne "in anger" shortly, but at this point
    I know next to nothing about it so I don't have any specific
    Tapestry/Cayenne advice at this point.

            Erik

    >
    > Robert



    This archive was generated by hypermail 2.0.0 : Thu Mar 31 2005 - 11:24:13 EST