That's a lot of good information for me to digest. Thanks.

On 2/12/06, Sebastiaan van Erk <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> See http://jakarta.apache.org/tapestry/UsersGuide/state.html. First of
> all you have a non-tapestry managed property; I don't know if it is
> automatically cleared when the page is returned to the pool.
>
> However, normally a page property is not persisted between requests but
> cleared as soon as the page goes back to the pool at the end of the
> request. To use session persistence you could do the following:
>
> public abstract class ProductPage extends BasePage {
>
>         @Persist("session")
>         public abstract Product product;
>
>         ...
> }
>
> Note that you make your class abstract and you only need to define an
> abstract getter, and tapestry will make the property for you, handle
> caching, clearing, etc..
>
> Another way to make this work without using the session is by passing
> for example the product id as argument to the listener, Then you don't
> need a session. However you will need to requery your object from the
> database. This should not be a problem if you use something like
> hibernate with ehcache, since it won't generally actually go to the
> database but just take the object out of the cache. The most fancy way
> to do this is to write your own DataSqueezer which "squeezes" your
> product to a product id and unsqueezes it by getting it back from the
> database. Then you can actually just pass the Product object as an
> argument without it being to heavy. See:
> http://wiki.apache.org/jakarta-tapestry/DataSqueezer
> for how to write a DataSqueezer.
>
> Hope this helps,
> Sebastiaan
>
> Matt Welch wrote:
> > Forgive the "newbness" of this question, but I'm just curious. Let's say
> if
> > have a page class similar to the following:
> >
> > public class ProductPage extends BasePage{
> >
> >   private Product product
> >   public getProduct(){return product;}
> >   public setProduct(Product product){this.product=product;}
> >
> >   @InjectPage("ExtraProductInfoPage");
> >   public abstract ExtraProductInfoPage getExtraProductInfoPage();
> >
> >   public ExtraProductInfoPage onClickExtraProductInfoLink(){
> >     getExtraProductInfoPage.setProduct(product);
> >     return getExtraProductInforPage();
> >   }
> > }
> >
> >
> > Ok, as you can see, I'm attempting to access a page property from within
> my
> > listener. the listener is called when someone clicks a DirectLink on the
> > ProductPage page. I'm guessing that this it is incorrect to access page
> > properties in this manner, because I'm having sporadic issues with the
> > product that I'm passing to the next page being null.
> >
> > First, am I correct in assuming what I'm trying to do here won't work?
> For
> > some reason, I thought I had understood that Tapestry used the session
> to
> > automatically maintain the page properties between the initial request
> and
> > the form submissions or links from the page that had been requested. I
> > assumed that this meant I could access the page properties from my
> listener
> > when it was called.
> >
> > If this usage is not correct, then is there a way to ensure that I can
> use
> > the Product object again in my listener without requerying it from my
> > database? I suppose I could pass the entire Product object as a
> parameter to
> > the DirectLink, but won't that produce a URl that's extremely heavy?
> >
> > Again, I apologize for what I'm sure is an uninformed question. I
> searched
> > the mail archives and wasn't able to discover an answer on my own.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to