Hi

>
> In some parts, facelets uses objects like the one before that are
>> serialized instead implements StateHolder or PartialStateHolder. It could be
>> good to know which strategy is better (serialization or implements
>> PartialStateHolder) and check in which cases it is worth to do it. One
>> example is CompositeComponentBeanInfo, but it could be others as well.
>>
>
> So what you are saying is that in this case it is better to use implements
> PartialStateHolder than serialization? I'll look for more situations where
> serialization is used and we shall discuss whether it is better to use
> PartialStateHolder instead.
>
>
Theorically, the advantage of use PartialStateHolder over serialization, is
that serialization needs to be saved and restored between requests, but
PartialStateHolder objects do not if the inner state is not changed, and if
so, it is necessary to save only the "delta".

Since in jsf we have "StateHolder" and "PartialStateHolder", we are assuming
serializable instances are immutable, so in most cases it is ok to use it.

I checked the code and we are not taking advantage of this assumption on
several places. For example: UIOutput.converter property. Maybe in this
place:

            else if (_isSetConverter() || _converter != null)
            {
                //Full
                converterSaved = saveAttachedState(facesContext,_converter);
                nullDelta = false;
            }

we can do this:

            else if (_isSetConverter() || (_converter != null &&
!(_converter instanceof Serializable) ))
            {
                //Full
                converterSaved = saveAttachedState(facesContext,_converter);
                nullDelta = false;
            }

but I haven't tested it fully yet.

In conclusion, in most cases both strategies are equivalent. But in this
time we don't know which strategy is faster.

For example, let's take the case of CompositeComponentBeanInfo. In theory,
after this object is initialized it does not change between requests (I mean
after the object is returned by vdl.getComponentMetadata(FacesContext,
Resource) ). In theory, PSS algorithm should not save it on the state, so on
each request we are setting it on the first request build. The only case we
have is if we are not using PSS on the current view or on that specific part
of the view by the effect of <c:if> tag. In that case we are
saving/restoring this value and the only relevant criteria to use
PartialStateHolder or serialization is speed.

 problem here is since this call occur in build time, we can't call
> getClientId() (it will cause problems because the parent for most components
> is null in this stage), so use a external map here
>
> Why not use the Reference of the component as the key? Over one request,
> the reference is stable enough!
>
>
Yes, it is possible. Just we have to take care about
ClientBehaviorRedirectEventComponentWrapper, because this class is used as a
wrapper to redirect client behavior events.

Note that CompositeComponentResourceTagHandler.ATTACHED_OBJECT_HADLERS_KEY
list is not saved on the state, but since we use the component attribute
map, the key and the null value is saved on the state. If we don't use the
component attribute map, we don't have that trace on the state and it will
be lower.

best regards,

Leonardo

Reply via email to