Gerhard,
since I have to account for concurrent changes of the underlying
business layer, I'm afraid things are a bit more complicated.
In general, getters/setters (and any listener) are the only available
triggers to load data while using request-scoped beans, as I do (many
request-scoped beans and one single session-scoped).
E.g. the bean is recreated from scratch at each request, so that data
must be reloaded or retrieved from cache or state saving.
Furthermore, I can't rely - while rendering - upon having my model
already prepared during a previous restore phase.
These two phases have different requirement:
- restoring *must* deal with the same model as saved during the
previous rendering, or troubles may occur if updating fields.
- rendering must reload data since the business layer might have
changed in between.
Thus in general - without full state saving such as in using
t:saveState, I need to load data twice. However the first time is not
really needed for readonly components. This is what I want to avoid by
speculating on how many times a model is requested.
-- Renzo
Gerhard Petracek wrote:
hello renzo,
i would suggest:
try to avoid loading data within getter methods.
so the question if you can rely on such mechanisms doesn't occur.
(if you really don't see a way to avoid loading data within getter
methods - i would use e.g. request-scoped custom flags -> don't load
data again, if the according flag exists/or contains a specific value.
or for other scenarios: if it is possible and you don't reference data
until you load it - check if data is already referenced or not...)
however, i think there are also other approaches to solve your
requirements. i just offered one (of ?) possible solution.
regards,
gerhard
2007/11/30, Renzo Tomaselli < [EMAIL PROTECTED]>:
Hi,
as many others - I'm trying to optimize loading data from my
business layer, avoiding to do it as much as possible while restoring a
view.
Now I noticed that components needing a complex data model as their
value (tree, table, etc.) ask the backing bean for this model exactly
twice: one while restoring, one while rendering. This is different than
normal getters which appear to be invoked a variable number of times.
The question is: how safe is to speculate on this behavior to decide
about current phase, and to arrange (or skip) data loading accordingly ?
-- Renzo
--
http://www.irian.at
Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German
Professional Support for Apache MyFaces