Inge,

Re-reading your post, I think I may have misunderstood part of your question. For situations like yours, I normally either let Tapestry persist the needed data (either request or session-scoped), or persist enough that I can reload everything in my form listener. I do not think however that reloading data during the rewind phase is a very good idea, since any change in the data between render and rewind will of course cause problems.

One method I've used which works pretty well is to implement a transient boolean initialRender property which is set by the invoking page. Within pageBeginRender, if this flag is set I know it is safe to clear all session-persistent page properties (except those which are essential for an initial render). This provides a simple but effective "page-visit persistence" scheme.

Shawn

Inge Solvoll wrote:
I would like to provoke some debate on whether this is a good design pattern
or not:

public void pageBeginRender(PageEvent event) {
  initState();
  readItemsFromDatabase();
}

private Collection readItemsFromDatabase() {
  return getDatabaseConnection().getItems();
}

private void initState() {
  // Init all crucial page state here
}

My problem is that some ids in hidden inputs are needed by the initState
method. These values are not available in the pageBeginRender method during
rewind, because the Hidden components containing them haven't been rendered
yet. I need this state information on a per-request basis, not per-session,
so it is not possible to persist the page property. So far, I'm solving this
by using good-old request parameters, and reading them the old servlet way
in the pageBeginRender method like this:

String crucialId = getRequest().getParameter("crucialId");
page.setCrucialId(new Long(crucialId));

I generally run into a lot of problems trying to find a good pattern for
setting up data to fit with the RequestCycle. I have ended up doing the
database reading in the pageBeginRender method, meaning that my data for the
page is being read on every single rewind and render. I find it a bit hard
to understand how to achieve this:

On render:
- Read data from database and set page properties

On rewind:
- Create non-null, empty, page properties ready to be populated from the
request.

My rewind step here often fails, and I don't see why. My page properties
don't seem to be populated, when I leave them as, say, a non-null empty
java.util.Collection to be populated with items from the request.

Long and not very concentrated post, I actually don't know where to start
here :)

Inge



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to