I am migrating application from JSF1.2/MyFaces+Facelets TO JSF2.1/MyFaces. I have following template which used to work with JSF1.2/MyFaces+Facelets.
<ui:component>
<f:subview id="#{id}">
.
.
<script
function blockLinkClicks(){
//Disables all the HyperLink Controls to prevent repeated submits
var allLinks = document.getElementById("#{id}:treeNodeForm").getElementsByTagName('a');
var count = allLinks.length;
.
.
</script>
.
.
.
<h:form id="treeNodeForm">
<h:panelGroup id="treePanelId">
<t:tree2 id="tree2Id"
value="#{treeBean.treeModel}" var="node" varNodeToggler="t"
binding="#{treeBean.component}" clientSideToggle="false" showNav="false">
<f:facet name="selectableNode">
<h:panelGrid id="tree2PGridSelNodeId" columns="3" cellpadding="0" cellspacing="0" border="0">
.
.
.
After migration, I am getting the following error:
java.lang.IllegalStateException: component with duplicate id "mainLeftTree:treeNodeForm:tree2Id:tree2PGridSelNodeId" found at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletUtils.java:100) at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletUtils.java:116)
I have found similar questions here in SO but I was not able to relate the solutions, with my above issue. I have tried to find solution for many days/hours but could not.
Please help with your advice and pointers that I can try for a fix, as I am not sure if the issue is with f:subview or t:tree2 or jsf2 facelets.
Thank you very much in advance.
Regards, Kumar.
I think the problem is caused by the use of <f:subview id="#{id}>"
, which obviously will break when PSS is enabled, because the EL is evaluated each time the view is built. Try first setting the web config parameter javax.faces.PARTIAL_STATE_SAVING to false. Or you can use the config parameter javax.faces.FULL_STATE_SAVING_VIEW_IDS to indicate which views needs full state saving. Maybe it is a good idea to avoid the EL in the id, and use other strategy in that part, but that could require some changes in the logic.