You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by michael lim <ji...@yahoo.com> on 2008/09/06 19:03:47 UTC
tacos @Cached in t4
in my page, i do like below, but when i press refresh F5 on page, i keep on
getting database hit. when using cached, aren't it not suppose to call
getFromDB() for subsequent call ?
@Cached
public String getGenerateMenuCached() {
return dao.getFromDb();
}
//in my dao
public String getFromDB(){
System.out.println("hit db");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: tacos @Cached in t4
Posted by michael lim <ji...@yahoo.com>.
my .application look like this
<library id="tacos" specification-path="/net/sf/tacos/Tacos.library"/>
<library id="dojo" specification-path="/net/sf/tacos/Dojo.library"/>
<library id="comet" specification-path="/net/sf/tacos/cometd/Cometd.library"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: tacos @Cached in t4
Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
I'm sorry, but what do you expect Tapestry to do about that? You're
explicity setting the property each time the page is loaded. @Persist
doesn't change that.
You'll need to check whether or not persistThisOne is not null before
assigning to it for this to work.
-Filip
On 2008-09-07 08:39, michael lim wrote:
> i tried this. whenever i press f5, pagebeginrender will still be called and db
> will be hit
>
>
> @Persist("session")
> public abstract Collection getPersistThisOne();
> public abstract void setPersistThisOne(Collection persistThisOne);
>
> public void pageBeginRender(PageEvent event) {
> System.out.println("pageBeginRender......");
>
> setPersistThisOne( dao.getFromDB());
>
>
> }
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: tacos @Cached in t4
Posted by michael lim <ji...@yahoo.com>.
i tried this. whenever i press f5, pagebeginrender will still be called and db
will be hit
@Persist("session")
public abstract Collection getPersistThisOne();
public abstract void setPersistThisOne(Collection persistThisOne);
public void pageBeginRender(PageEvent event) {
System.out.println("pageBeginRender......");
setPersistThisOne( dao.getFromDB());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: tacos @Cached in t4
Posted by Kalle Korhonen <ka...@gmail.com>.
You've misunderstood the purpose of @Cached. The documentation (
http://tacos.sourceforge.net/tacos4.1/tacos-annotations/index.html) says:
"The Cached
<http://tacos.sourceforge.net/tacos4.1/apidocs/net/sf/tacos/annotations/Cached.html>annotation
allows you to cache the results of a pag/component method for the
lifetime of a single request. It can be attached to any non-private,
non-abstract method:". When you press F5 you are creating a new request. You
might be looking for @Persist instead; you use it with an abstract property
that you populate somewhere else, for example in pageBeginRender.
Kalle
On Sat, Sep 6, 2008 at 10:03 AM, michael lim <ji...@yahoo.com> wrote:
> in my page, i do like below, but when i press refresh F5 on page, i keep on
> getting database hit. when using cached, aren't it not suppose to call
> getFromDB() for subsequent call ?
>
>
> @Cached
> public String getGenerateMenuCached() {
>
>
> return dao.getFromDb();
> }
>
>
>
>
> //in my dao
> public String getFromDB(){
>
> System.out.println("hit db");
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>