Good afternoon.

I've been trying for some time to figure a way to properly use t:saveState.

I've been able to easily use its core functionality of keeping state between
successive requests.
However, for beans which are supposed to carry information from a database
to be presented on the screen, one must initialize its properties. And thus
I'd like to have a specific method on my beans which would be called
whenever such initialization is needed. For now, I'm using the setter of a
managed-property on my bean - which is called everytime a new request is
processed for that bean.

Now comes the tricky part: I want to avoid going to the database and
retrieving the data I've already collected. So I use t:saveState for that.
And I've set a private boolean in the bean which is checked on the
initialization method before going to the database once more... the problem
is, it seems to me, that when my init method runs, t:saveState's bean
restoration process has not yet occurred and so the private boolean that
carries the information on whether the bean has already been initialized is
still set to false - so it goes to the database once more (and later the
restore takes place over the newly acquired data). As you can see I need to
switch the order of these two steps...

So what I'm looking for is a standard (or non-standard) way of invoking a
method on my bean everytime a page uses that bean, but only after the
t:saveState component has properly restored the bean. And obviously the
solution I'm looking for must also call this method for the first access to
the page, where there is no state for the component to restore.

Is there already a solution for this?

Thank you,
Francisco Passos

Reply via email to