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

Leonardo Uribe commented on MYFACES-3447:
-----------------------------------------

Unfortunately it is not possible, because the parent component will always be 
UIViewRoot, so the clientId will be the the same id. In practice you never set 
id for resources, because it has no use at all.
                
> Invalid Id check in the UIViewRoot.addComponentResource method
> --------------------------------------------------------------
>
>                 Key: MYFACES-3447
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3447
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.1.3, 2.1.4, 2.1.5
>         Environment: Glassfish 3.1 y jdk1.6
>            Reporter: Juan Fernandez Corugedo
>            Assignee: Leonardo Uribe
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> The method addComponentResource of the class UIViewRoot makes a check over 
> the Id attribute of each component that will be inserted into the 
> componentResources list:
> <code>
>         // If the component ID of componentResource matches the ID of a 
> resource that has already been added, remove the old resource.
>         String componentId = componentResource.getId();
>        ...
>         else if (componentId != null)
>             {
>                 for(Iterator<UIComponent> it = componentResources.iterator(); 
> it.hasNext();)
>                 {
>                     UIComponent component = it.next();
>                     if(componentId.equals(component.getId()) && 
> componentResource != component)
>                     {
>                         it.remove();
>                     }
>                     else if (componentResource == component)
>                     {
>                         alreadyAdded = true;
>                     }
>                 }
>             }
> </code>
> As you can see, if there are two components with the same Id but different 
> clientId, only one of them will be included in the header:
> <bks:outputStylesheet id="testStyle" library="css1" name="test1.css"/> <!-- 
> Its clientId is testStyle -->
> <form id="form">
> ...
> <bks:outputStylesheet id="testStyle" library="css2" name="test2.css"/> <!-- 
> Its clientId is form:testStyle -->
> ...
> </form>
> This situtation can be solved using the clientId instead of the id attribute:
> <code>
>         // If the component CLIENT_ID of componentResource matches the 
> CLIENT_ID of a resource that has already been added, remove the old resource.
>         String componentId = componentResource.getClientId();
> </code>
>        

--
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

        

Reply via email to