You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org> on 2014/05/14 14:15:17 UTC

[jira] [Commented] (MYFACES-3890) Component added using vdl.createComponent(...) is removed when javax.faces.FACELETS_REFRESH_PERIOD is not -1

    [ https://issues.apache.org/jira/browse/MYFACES-3890?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13997493#comment-13997493 ] 

Leonardo Uribe commented on MYFACES-3890:
-----------------------------------------

After checking the code, I found the problem is caused by a small bug on DefaultFacelet.applyCompositeComponent(...). There are some lines that says this:

DefaultFacelet f = (DefaultFacelet) _factory.getFacelet(resource.getURL());

this.refresh(parent);
....
this.markApplied(parent);

The code retrieve the facelet to use in the composite component, but it applies the refresh()/markApplied of the current facelet. Internally, this.refresh(...) has some references to private variables like createTime, alias and so on, so the refresh is done taking the time of the source facelet, not the composite component facelet. For example, if you edit a composite component, this bug causes the changes done inside composite component facelet file are not reflected properly, and the component will not be flushed unless you edit the parent file.

The fix is simple, just use f. instead this. That should be enough, because  DefaultFacelet.applyDynamicComponentHandler(...) does not contains that logic (and it shouldn't).

> Component added using vdl.createComponent(...) is removed when javax.faces.FACELETS_REFRESH_PERIOD is not -1
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-3890
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3890
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-344
>    Affects Versions: 2.2.3
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>            Priority: Minor
>
> On the way of implement MYFACES-3733 "Implement vdl.createComponent(...)", it was noticed that when javax.faces.FACELETS_REFRESH_PERIOD config param is different from -1, the programmatically added component dissapear after a postback. 
> The problem happens because the code in vdl.createComponent(...) does an "inline compilation" of a facelet instance of the component, but the original algorithm does not consider that case. Instead, all facelets are stored in a structure and the refresh period is used to decide when a facelet instance needs to be reloaded.
> The inline compilation makes a new facelet instance to be created every time the component needs to be created or refreshed. The algorithm done in this part is ok, the only thing that needs to be done is disable the refresh on the sections that are compiled inline.
> Unfortunately things are not so simple, because for example in a composite component there are two facelets involved: one that makes the inline compilation and the other that renders the component and is reused over and over again. So, we need to review the algorithm to be sure everything is ok.



--
This message was sent by Atlassian JIRA
(v6.2#6252)