Description
The following error occurs when a JSF component adding a resource is added in a JSTL tag handler:
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) [...]
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!