You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "dennis hoersch (Created) (JIRA)" <de...@myfaces.apache.org> on 2012/03/28 09:36:37 UTC

[jira] [Created] (MYFACES-3515) Duplicate id using a facet in a composite component

Duplicate id using a facet in a composite component
---------------------------------------------------

                 Key: MYFACES-3515
                 URL: https://issues.apache.org/jira/browse/MYFACES-3515
             Project: MyFaces Core
          Issue Type: Bug
         Environment: MyFaces 2.1.4, Tomahawk20 1.1.11
            Reporter: dennis hoersch


Hello,

I get an IllegalStateException using a facet in a composite component. The facet gets the same id as the internal 'composite component'-facet. The facet is created using CumponentSupport.addFacet(). Here the id of the facet is generated using the view root instead of the UniqueIdVendor of the parent to whom the facet is added.

In other places the id is retrieved with something like

        FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(facesContext);
        UniqueIdVendor uniqueIdVendor = mctx.getUniqueIdVendorFromStack();
        if (uniqueIdVendor == null)
        {
            uniqueIdVendor = facesContext.getViewRoot();
        }
	String uid = uniqueIdVendor.createUniqueId(facesContext, null);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Issue Comment Edited] (MYFACES-3515) Duplicate id using a facet in a composite component

Posted by "dennis hoersch (Issue Comment Edited) (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13240464#comment-13240464 ] 

dennis hoersch edited comment on MYFACES-3515 at 3/28/12 3:15 PM:
------------------------------------------------------------------

I have attatched an example:
- one simple faces site
- one simple composite component with a facet
                
      was (Author: hoersch):
    Example
                  
> Duplicate id using a facet in a composite component
> ---------------------------------------------------
>
>                 Key: MYFACES-3515
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3515
>             Project: MyFaces Core
>          Issue Type: Bug
>         Environment: MyFaces 2.1.6, Tomahawk20 1.1.11
>            Reporter: dennis hoersch
>         Attachments: duplicateIdTest.zip
>
>
> Hello,
> I get an IllegalStateException using a facet in a composite component. The facet gets the same id as the internal 'composite component'-facet. The facet is created using CumponentSupport.addFacet(). Here the id of the facet is generated using the view root instead of the UniqueIdVendor of the parent to whom the facet is added.
> In other places the id is retrieved with something like
>         FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(facesContext);
>         UniqueIdVendor uniqueIdVendor = mctx.getUniqueIdVendorFromStack();
>         if (uniqueIdVendor == null)
>         {
>             uniqueIdVendor = facesContext.getViewRoot();
>         }
> 	String uid = uniqueIdVendor.createUniqueId(facesContext, null);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (MYFACES-3515) Duplicate id using a facet and multiple blocks in a composite component

Posted by "Leonardo Uribe (Resolved) (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-3515?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe resolved MYFACES-3515.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.1.7
                   2.0.13
         Assignee: Leonardo Uribe
    
> Duplicate id using a facet and multiple <c:if> blocks in a composite component
> ------------------------------------------------------------------------------
>
>                 Key: MYFACES-3515
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3515
>             Project: MyFaces Core
>          Issue Type: Bug
>         Environment: MyFaces 2.1.6, Tomahawk20 1.1.11
>            Reporter: dennis hoersch
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.13, 2.1.7
>
>         Attachments: duplicateIdTest.zip
>
>
> Hello,
> I get an IllegalStateException using a facet in a composite component. The facet gets the same id as the internal 'composite component'-facet. The facet is created using CumponentSupport.addFacet(). Here the id of the facet is generated using the view root instead of the UniqueIdVendor of the parent to whom the facet is added.
> In other places the id is retrieved with something like
>         FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(facesContext);
>         UniqueIdVendor uniqueIdVendor = mctx.getUniqueIdVendorFromStack();
>         if (uniqueIdVendor == null)
>         {
>             uniqueIdVendor = facesContext.getViewRoot();
>         }
> 	String uid = uniqueIdVendor.createUniqueId(facesContext, null);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (MYFACES-3515) Duplicate id using a facet in a composite component

Posted by "Leonardo Uribe (Commented) (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13240372#comment-13240372 ] 

Leonardo Uribe commented on MYFACES-3515:
-----------------------------------------

Could you provide an example to be able to reproduce this issue? 
                
> Duplicate id using a facet in a composite component
> ---------------------------------------------------
>
>                 Key: MYFACES-3515
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3515
>             Project: MyFaces Core
>          Issue Type: Bug
>         Environment: MyFaces 2.1.6, Tomahawk20 1.1.11
>            Reporter: dennis hoersch
>
> Hello,
> I get an IllegalStateException using a facet in a composite component. The facet gets the same id as the internal 'composite component'-facet. The facet is created using CumponentSupport.addFacet(). Here the id of the facet is generated using the view root instead of the UniqueIdVendor of the parent to whom the facet is added.
> In other places the id is retrieved with something like
>         FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(facesContext);
>         UniqueIdVendor uniqueIdVendor = mctx.getUniqueIdVendorFromStack();
>         if (uniqueIdVendor == null)
>         {
>             uniqueIdVendor = facesContext.getViewRoot();
>         }
> 	String uid = uniqueIdVendor.createUniqueId(facesContext, null);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (MYFACES-3515) Duplicate id using a facet in a composite component

Posted by "Leonardo Uribe (Commented) (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13240949#comment-13240949 ] 

Leonardo Uribe commented on MYFACES-3515:
-----------------------------------------

I was not able to reproduce the bug, but I can see the problem. The reason why we haven't seen it is any call to UIViewRoot.createUniqueId() increase the unique counter, so as soon as the view gets bigger and bigger, the different between the unique counter in UIViewRoot and other counters in composite components gets bigger too. In few words, the probability to see the problem is very small, but I'm glad someone has been able to see it.

The panel created by ComponentSupport.createFacetUIPanel is special. To be restored properly and do not create duplicate ids or any other unwanted conflicts, it requires an unique id. This code is usually called when more than one component is added to a facet and it is necessary to create a shared container. Use FaceletCompositionContext.generateUniqueComponentId() is not possible, because <c:if> blocks inside a facet will make component ids unstable. Use UniqueIdVendor is feasible but also will be affected by <c:if> blocks inside a facet. The only solution that will generate real unique ids is use the parent id and the facet name and derive an unique id that cannot be generated by SectionUniqueIdCounter, doing the same trick as with metadata: use a double __ and add a prefix (f). Note this id will never be printed into the response, because this is just a container.

Note in facelets 1.1.x facets requires a container component, but in JSF 2.0 / 2.1, the behavior to handle facets was changed in order to make f:metadata component work (requires facets can contain more than one component automatically).

I also have notice a small performance improvement: our calls to UniqueIdVendor.createUniqueId() increase the unique counter in 1, but when a seed is passed this is not necessary. That will save one HashMap.get() call per component create by facelets.
                
> Duplicate id using a facet in a composite component
> ---------------------------------------------------
>
>                 Key: MYFACES-3515
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3515
>             Project: MyFaces Core
>          Issue Type: Bug
>         Environment: MyFaces 2.1.6, Tomahawk20 1.1.11
>            Reporter: dennis hoersch
>         Attachments: duplicateIdTest.zip
>
>
> Hello,
> I get an IllegalStateException using a facet in a composite component. The facet gets the same id as the internal 'composite component'-facet. The facet is created using CumponentSupport.addFacet(). Here the id of the facet is generated using the view root instead of the UniqueIdVendor of the parent to whom the facet is added.
> In other places the id is retrieved with something like
>         FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(facesContext);
>         UniqueIdVendor uniqueIdVendor = mctx.getUniqueIdVendorFromStack();
>         if (uniqueIdVendor == null)
>         {
>             uniqueIdVendor = facesContext.getViewRoot();
>         }
> 	String uid = uniqueIdVendor.createUniqueId(facesContext, null);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira