Hi Nick, thanks for this response.
The next question is probably to be decided by the Tapestry developers,
but maybe somebody else has some insights on this or knows if this has
been discussed before:
Would it not make more sense to be able to specify a "attach-value" and
a "detach-value" instead of a "initial-value"?
This way I could explicitly specify two different values for the two
points in time of the page's lifecycle. I could do:
<property name="myList" attach-value="ognl:service.loadListFromDb()"
detach-value="ognl:null"/>
The reason being that it doesn't seem to make much sense to perform
resource-expensive operations like DB queries for cleanup AFTER the page
is used. As far as I understand, this post-use initialization is mainly
done to prevent data that belongs to one user from being "accidentally"
carried over to the next user.
So setting the property to null when the page is returned to the pool
should be enough for that purpose. Especially since by the time the next
user gets the page from the pool, the cached value might long be outdated.
On the other hand, this idea sounds too simple for it to never have come
up before, so maybe there is a good reason against it?!
Thanks,
MARK
Nick Westgate wrote:
Hi Mark.
The "initial-value" attribute is poorly named.
What it does is initialize your page property when the page
is being *returned* to the pool, so that a page pulled from
the pool has this "initial" property value.
Of course, to facilitate the above, when a page is first
constructed it must be initialized. That's why you're seeing
two invocations: on construction and on return to the pool.
I suggest you carefully read this entire section:
http://jakarta.apache.org/tapestry/UsersGuide/state.html#state.page-properties
And the FAQ "Where do I "initialize" values for a page?":
http://wiki.apache.org/tapestry/MoreFrequentlyAskedQuestions
I'm still using T3, not 4, and I use the PageRenderListener approach:
public void pageBeginRender(PageEvent event)
{
// initialize properties etc
if (!event.getRequestCycle().isRewinding())
{
if (getXXX() == null)
{
...
setXXX(...);
}
}
}
Cheers,
Nick.
Mark wrote:
Hi Ron,
it sounds like this would work, but isn't this just a workaround for
something that really should not happen this way in the first place?
Thanks,
MARK
...
<property
name="roomList">ognl:administrationService.getAllRooms()</property>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]