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

Volodymyr Siedlecki commented on MYFACES-4623:
----------------------------------------------

c:forEach has given us lots of problems in the past (such as MYFACES-4318). 

However, the code you found above was added in MYFACES-3883 and it looks like 
work around:  " The idea is detect the duplicate when the component is added to 
the tree and remove the invalid component and replace it with the restored 
one."   

I stepped through the code and saw the jakarta.faces.component.UIOutput was not 
"MARK_CREATED", so the duplicate entry was added as a child of the 
ComponentResourceContainer target.  I can try to look a bit further into this 
(perhaps find a way to mark the component), but I'm not sure if we are able to 
fix as it looks like PSS and c:forEach are a bit broken when used together.

> 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