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.5, 2.1.4, 2.1.3
Environment: Glassfish 3.1 y jdk1.6
Reporter: Juan Fernandez Corugedo
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