2 Replies Latest reply on Aug 5, 2008 4:48 PM by Brian Kates

    AjaxStateManager duplicate Id for a component exception

    Brian Kates Newbie

      I posted this on the users forum, but I need to talk to someone technical.

      We have an existing application that's roughly a year and a half old built using myFaces, Tomahawk, JSPs, tiles, and other open source components. A few months ago we added RichFaces to the mix, but have experienced nothing but grief with AjaxStateManager duplicate id exceptions. A typical exception is as follows:

      duplicate Id for a component body:processForm:stateHistory_tab:claimStateHistory:_idJsp329
      at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.apply(AjaxStateManager.java:442)
       at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.apply(AjaxStateManager.java:464)
      ... etc
      



      Of note is that we seem to encounter these problems on tabs with subviews and included JSPs. It happens consistently after loading and viewing something twice. For example, in our application we can view an insurance claim or process the insurance claim by assigning it to yourself. If I view the claim, hit the browser back, and then press the command link to assign the claim to me, I consistently get a duplicate id exceptions. We NEVER had these exceptions before introducing RichFaces into the mix.

      Breaking down the id in the exception:

      "body": the body
      "processForm": the form
      "stateHistory_tab": The id of the subview
      "claimStateHistory": An id for a panel grid with seven columns
      "_idJsp329": unknown generated id

      Unfortunately the source html does not full generate and I can't tell where (or what) the duplicate id is. In other words, I view source and the duplicate is "idJsp329" is not there in the html.

      Is there a solution to these problems? We're currently using RichFaces 1.1.4. We tried upgrading to later versions, but none of them worked due to other flaws with RichFaces (not sending f:param, server state saving, etc).

      Versions of the open source projects we use are:
      MyFaces 1.1.4
      Tomahawk 1.1.2
      RichFaces 3.1.4

      Note that we use JSPs and tiles.

      I thought it best to add a code snippet. We have the following setup:

      <h:form id="processForm" >
      
      <t:panelTabbedPane bgcolor="#FFFFCC" width="100%" id="piTabs"
       binding="#{myBackingBean.tabbedPane}"
       serverSideTabSwitch="false"
       activeTabStyleClass="activeTab"
       tabContentStyleClass="tabContent">
      
      
       <f:subview id="stateHistory_tab" >
       <jsp:include page="claimProcessStateHistory.jsp"/>
       </f:subview>
      
       </t:panelTabbedPane>
      
      </h:form>


      There are no duplicates on the inserted jsp, but the mere fact that it is inserted as a subview seems to cause RichFaces all sorts of grief.

        • 1. Re: AjaxStateManager duplicate Id for a component exception
          Brian Kates Newbie

          I did some additional research and found some interesting results. I put a breakpoint in the AjaxStateManager around this section of code:

          String clientId = component.getClientId(context);
          if (!uniqueIds.add(clientId)) {
           throw new IllegalStateException("duplicate Id for a component "+ clientId);
          }


          I made the breakpoint conditional to only stop for the duplicate id. The ids of the duplicates were:

          body:form:tab:table:component id

          in both cases, the component was output text and the id was "_idJsp317".

          Here's the interesting part: not that the column was missing. When I inspected the component's parent through the debugger, it had an id of:

          body:form:tab:table:component id. (this was expected)

          In both cases, the component's parent (the column) had a unique id. So why isn't parent id being included along with the child? For example, for a component in a data table column, I would expect an id of:

          body:form:tab:table:column:component id but the ids that are generated are body:form:tab:table:component id (thus resulting in a duplicate id).

          Question: prior to migrating to rich races, we used A4J. How come we never encountered this problem before? Is this a case of rich faces having more stringent id checking? Or is rich faces doing something to generate the ids? Note that it is a tomahawk (1.1.4) data table.

          Thanks.

          • 2. Re: AjaxStateManager duplicate Id for a component exception
            Brian Kates Newbie

            Can someone explain to me what the AjaxStateManager in the 3.1.x branch is doing and why it is generating all sorts of duplicate id exceptions? I looked at the old ajax4jsf code and there was no AjaxStateManager class (it didn't exist). I looked at the latest 3.2.x code and the "apply" method that throws the exception is gone. In fact the class was totally revamped.