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

Manuel K commented on MYFACES-4623:
-----------------------------------

What I found so far:

The resource component is added to the children of the 
"jakarta_faces_location_head" a second time in 
PartialStateManagementStrategy$AddComponentCallback#invokeContextCallback().

Right above there is the following if-statement with this interesting comment:
{code:java}
// Is the child a facelet controlled component?
if (child.getAttributes().containsKey(ComponentSupport.MARK_CREATED))
{
    // By effect of c:forEach it is possible that the component can be 
duplicated
    // in the component tree, so what we need to do as a fallback is replace the
    // component in the spot with the restored version. {code}
But in this case the if evaluates to false and the resource component is added 
a second time. I don't yet know what the MARK_CREATED attribute is.

> DuplicateIdException when adding component with resource in JSTL tag handler
> ----------------------------------------------------------------------------
>
>                 Key: MYFACES-4623
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4623
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 4.0.1
>            Reporter: Manuel K
>            Priority: Major
>
> The following error occurs when a JSF component adding a resource is added in 
> a JSTL tag handler:
> {code:java}
> org.apache.myfaces.view.facelets.compiler.DuplicateIdException: Component 
> with duplicate id "j_id__rd_5" found. The first component is {Component-Path 
> : [Class: jakarta.faces.component.UIViewRoot,ViewId: /test.xhtml][Class: 
> org.apache.myfaces.component.ComponentResourceContainer,Id: 
> jakarta_faces_location_head][Class: jakarta.faces.component.UIOutput,Id: 
> j_id__rd_5]}
>     at 
> org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.createAndQueueException(CheckDuplicateIdFaceletUtils.java:139)
>     at 
> org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletUtils.java:95)
>     at 
> org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletUtils.java:109)
>     at 
> org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletUtils.java:103)
>     at 
> org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletUtils.java:81)
>     at 
> org.apache.myfaces.view.facelets.PartialStateManagementStrategy.saveView(PartialStateManagementStrategy.java:701)
>     at 
> jakarta.faces.application.StateManager.getViewState(StateManager.java:147)
> [...]{code}
> In our example, the resource that is apparently added to the component tree 
> twice is _inputmask/inputmask.js_ of the _p:calendar_ component when using it 
> in a {_}c:forEach{_}.
> The error only happens if _STRICT_JSF_2_FACELETS_COMPATIBILITY_ is enabled, 
> but that is a requirement for our application. The error does not occur in 
> Mojarra.
> I would appreciate you looking into this, as it is a pretty big problem for 
> us. And before you ask: We're using c:forEach because in our application 
> changing from c:forEach/c:if to ui:repeat/ui:fragment would result in an 
> increase of components in the component tree by a factor of about 5 on some 
> sites.
> I could copy and paste more of the code here, but I think it's easier to just 
> look at the reproducer: 
> [https://github.com/mkomko/primefaces-test/tree/inputmask-duplicateid]
> The error occurs when opening the dialog using the button and then clicking 
> "Cancel".
> Thank you very much in advance!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to