[ https://issues.apache.org/jira/browse/MYFACES-4631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17773764#comment-17773764 ]
Volodymyr Siedlecki edited comment on MYFACES-4631 at 10/10/23 5:52 PM: ------------------------------------------------------------------------ Some more information I discovered while trying to create a test. This problem is more complicated than I thought. Unique IDs are are created for children here: [https://github.com/apache/myfaces/blob/9ad559ac3b5ca4523b152ffef15c5cff7d4c55d4/api/src/main/java/jakarta/faces/component/UIComponentBase.java#L903] However, the problem in this primefaces extension is the restore. Somehow, the uniqueIdCounter is no longer unique. My theory is that this relates to the restore view and how the states are saved based on my logging of UIViewRoot.PropertyKeys.uniqueIdCounter. Logging of put calls in the delta helper for UIViewRoot.PropertyKeys.uniqueIdCounter Request 1: PropertyKeys.uniqueIdCounter 1 PropertyKeys.uniqueIdCounter 2 PropertyKeys.uniqueIdCounter 3 PropertyKeys.uniqueIdCounter 4 PropertyKeys.uniqueIdCounter 5 Request 2: PropertyKeys.uniqueIdCounter 1 PropertyKeys.uniqueIdCounter 5 PropertyKeys.uniqueIdCounter 6 UIComponentBase RESTORE STATE! DELTA RESTORE! PropertyKeys.uniqueIdCounter 7 <---- Request 3: PropertyKeys.uniqueIdCounter 1 PropertyKeys.uniqueIdCounter 7 <---- Reused PropertyKeys.uniqueIdCounter 8 UIComponentBase RESTORE STATE! DELTA RESTORE! PropertyKeys.uniqueIdCounter 7 PropertyKeys.uniqueIdCounter 7 UIComponentBase RESTORE STATE! DELTA RESTORE! UIComponentBase RESTORE STATE! DELTA RESTORE! PropertyKeys.uniqueIdCounter 8 UIComponentBase RESTORE STATE! DELTA RESTORE! UIComponentBase RESTORE STATE! DELTA RESTORE! <UIOutput id="j_id__v_7" clientBehaviors="{}" clientId="j_id__v_7" converter="NULL" defaultEventName="NULL" eventNames="NULL" facetCount="0" family="javax.faces.Output" inView="true" localValue="NULL" namingContainer="NULL" passThroughAttributes="javax.faces.component._PassThroughAttributesMap@0" rendered="true" rendererType="javax.faces.resource.Script" rendersChildren="true" resourceBundleMap="{}" transient="false" transientStateHelper="javax.faces.component._DeltaStateHelper@6ac73526"> <UIOutput id="j_id__v_7" clientBehaviors="{}" clientId="j_id__v_7" converter="NULL" defaultEventName="NULL" eventNames="NULL" facetCount="0" family="javax.faces.Output" inView="true" localValue="if(window.PrimeFaces)\{PrimeFaces.settings.locale='en_US';PrimeFaces.settings.viewId='/test.xhtml';PrimeFaces.settings.contextPath='/primefaces-test-1.0-SNAPSHOT';PrimeFaces.settings.cookiesSecure=false;PrimeFaces.settings.projectStage='Development';}" namingContainer="NULL" passThroughAttributes="javax.faces.component._PassThroughAttributesMap@0" rendered="true" rendererType="javax.faces.Text" rendersChildren="false" resourceBundleMap="{}" transient="false" transientStateHelper="javax.faces.component._DeltaStateHelper@1ada818"/> </UIOutput> was (Author: volosied): Some more information I discovered while trying to create a test. This problem is more complicated than I thought. Unique IDs are are created for children here: [https://github.com/apache/myfaces/blob/9ad559ac3b5ca4523b152ffef15c5cff7d4c55d4/api/src/main/java/jakarta/faces/component/UIComponentBase.java#L903] However, the problem in this primefaces extension is the restore. Somehow, the uniqueIdCounter is no longer unique. My theory is that this relates to the restore view and how the states are saved based on my logging of UIViewRoot.PropertyKeys.uniqueIdCounter. Logging of put calls in the delta helper for UIViewRoot.PropertyKeys.uniqueIdCounter Request 1: PropertyKeys.uniqueIdCounter 1 PropertyKeys.uniqueIdCounter 2 PropertyKeys.uniqueIdCounter 3 PropertyKeys.uniqueIdCounter 4 PropertyKeys.uniqueIdCounter 5 Request 2: PropertyKeys.uniqueIdCounter 1 PropertyKeys.uniqueIdCounter 5 PropertyKeys.uniqueIdCounter 6 UIComponentBase RESTORE STATE! DELTA RESTORE! PropertyKeys.uniqueIdCounter 7 Request 3: PropertyKeys.uniqueIdCounter 1 PropertyKeys.uniqueIdCounter 7 PropertyKeys.uniqueIdCounter 8 UIComponentBase RESTORE STATE! DELTA RESTORE! PropertyKeys.uniqueIdCounter 7 PropertyKeys.uniqueIdCounter 7 UIComponentBase RESTORE STATE! DELTA RESTORE! UIComponentBase RESTORE STATE! DELTA RESTORE! PropertyKeys.uniqueIdCounter 8 UIComponentBase RESTORE STATE! DELTA RESTORE! UIComponentBase RESTORE STATE! DELTA RESTORE! <UIOutput id="j_id__v_7" clientBehaviors="{}" clientId="j_id__v_7" converter="NULL" defaultEventName="NULL" eventNames="NULL" facetCount="0" family="javax.faces.Output" inView="true" localValue="NULL" namingContainer="NULL" passThroughAttributes="javax.faces.component._PassThroughAttributesMap@0" rendered="true" rendererType="javax.faces.resource.Script" rendersChildren="true" resourceBundleMap="{}" transient="false" transientStateHelper="javax.faces.component._DeltaStateHelper@6ac73526"> <UIOutput id="j_id__v_7" clientBehaviors="{}" clientId="j_id__v_7" converter="NULL" defaultEventName="NULL" eventNames="NULL" facetCount="0" family="javax.faces.Output" inView="true" localValue="if(window.PrimeFaces)\{PrimeFaces.settings.locale='en_US';PrimeFaces.settings.viewId='/test.xhtml';PrimeFaces.settings.contextPath='/primefaces-test-1.0-SNAPSHOT';PrimeFaces.settings.cookiesSecure=false;PrimeFaces.settings.projectStage='Development';}" namingContainer="NULL" passThroughAttributes="javax.faces.component._PassThroughAttributesMap@0" rendered="true" rendererType="javax.faces.Text" rendersChildren="false" resourceBundleMap="{}" transient="false" transientStateHelper="javax.faces.component._DeltaStateHelper@1ada818"/> </UIOutput> > DuplicateIdException via addComponentResource > --------------------------------------------- > > Key: MYFACES-4631 > URL: https://issues.apache.org/jira/browse/MYFACES-4631 > Project: MyFaces Core > Issue Type: Bug > Affects Versions: 2.3.10, 3.0.2, 2.3-next-M8, 4.0.1 > Reporter: Volodymyr Siedlecki > Priority: Major > > See Bug Report here: > [https://github.com/primefaces-extensions/primefaces-extensions/issues/517] > > [https://github.com/omnifaces/omnifaces/wiki/Combine-hardcoded-PrimeFaces-resources-using-CombinedResourceHandler] > > See comment here for root cause: > [https://github.com/primefaces-extensions/primefaces-extensions/issues/517#issuecomment-1688911766] > {{{}I saw we had a id counter and it starts at 0 before the state is stored. > So when the script is added, it's always using the same counter. [ See > here.|https://github.com/apache/myfaces/blob/304099d4588383424df9105d5a751911c1c5301a/api/src/main/java/jakarta/faces/component/UIViewRoot.java#L493-L495]{}}}{{{}I > think the main issue is that we aren't adding ids to the nested items here: > [https://github.com/apache/myfaces/blob/304099d4588383424df9105d5a751911c1c5301a/api/src/main/java/jakarta/faces/component/UIViewRoot.java#L218-L224]{}}} > {{We need to look at the children and also assign IDs. }} > {{Only issue I see above is that I search only the immediate children and > don't drill down any further. Otherwise, it seems to fix the duplicate id > exception :)}} -- This message was sent by Atlassian Jira (v8.20.10#820010)