myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leonardo Uribe <lu4...@gmail.com>
Subject Re: PostAddViewEvent - must it be fired on postback again?
Date Thu, 22 Jan 2015 01:15:26 GMT
Hi Thomas

PostAddToView should be called only once, when the component is added
to the view.

But when the view is restored with PSS enabled, the initial view calls
PostAddToView, but the fact is if the algorithm is properly
implemented, you shouldn't notice anything, as it was implemented in
MyFaces. The reason of this behavior is the algorithm must ensure the
view is created doing exactly the same steps as when the view was
built by first time. PostAddToView can be used to create or add some
components to the component tree.

Remember that when PSS is disabled, the extra call does not happen.
But the user will not notice anything, things will work just the same.

The problem with PostAddToView is you need to call it exactly once,
because otherwise you could create duplicate components or have
problems like the one you described.

The problem is the state saving algorithm and facelets algorithm have
some side effects with PostAddToView. Facelets removes and adds
components to the tree, the state saving algorithm could trigger
component addition. So the algorithm must be carefully designed to
decide when and where to call it or not.

Why it works in MyFaces and doesn't work in Mojarra? I suppose it is
because the implementation is different. But in my opinion the right
behavior is the one implemented in MyFaces.

In conclusion, with PSS enabled, the extra call should be done, but
only when the initial view is built. After that, the view state must
be restored in a way that avoid any extra call to PostAddToViewEvent.

regards,

Leonardo Uribe

2015-01-21 16:53 GMT-05:00 Thomas Andraschko <andraschko.thomas@gmail.com>:
> Hi (Leo),
>
> i wonder if the PostAddToView-Event must be called again on postback if the
> component was already available on the initial request?
>
> I developed a PostAddToView listener for PrimeFaces to dynamically add a
> maxlength attribute to the input components.
> I expected that the PostAddToView event will only be fired once and not
> again on postback.
> This is exactly what happens in MyFaces, but it will be called again on
> postback in Mojarra.
>
> I created a ticket for Mojarra but they say that it works as designed ->
> https://java.net/jira/browse/JAVASERVERFACES-3516
>
> What do you think is the correct way?
>
> Regards,
> Thomas

Mime
View raw message