5 Replies Latest reply on Sep 5, 2008 11:46 AM by J D

    duplicate Id for a component _id0 from dnd example

    J D Newbie

      Hi,
      I'm adapting the dnd code from the example at
      http://livedemo.exadel.com/richfaces-demo/richfaces/dragSupport.jsf and the drop listener code in my bean is working fine in doing the changes I want on each drag and drop but when ajax tries to refresh the zone (after each drop) I get errors being logged -
      Aug 29, 2008 12:18:57 PM com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/demo_doc.xhtml]
      java.lang.IllegalStateException: duplicate Id for a component _id0
      at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.apply(AjaxStateManager.java:442)

      So nothing actually refreshes and something weird is going on in the autogenerated ids from jsf/richfaces tags - component tree stacktrace is not showing any elements with _id0 so not sure where it's being introduced.

      But if I then manually refresh the page thru the browser after doing a few drag-n-drops while this error gets logged each drop, the page does accurately reflect the changes that should have happened which is how i confirmed the drop code was at least working (the manual refresh only works in IE though, in FF it will still persist with the jsf stack trace error page). Any thoughts or ideas - I'm using richfaces 3.1.2 (i've tried 3.2+ but my drop event code doesn't get executed at all for some reason when using those versions) and myfaces 1.1.4 and jsf-facelets-1.1.11. Thanks.

        • 1. Re: duplicate Id for a component _id0 from dnd example
          J D Newbie

          This is the exact code I'm using in my facelet adapted from that example - I added id's everywhere seeing if that would solve anything but no luck:

          <rich:dragIndicator id="indicator" />
          
          <form id="form1" name="form1" method="post" action="/app/demo_doc.xhtml" enctype="application/x-www-form-urlencoded">
           <h:panelGrid columnClasses="panelc" columns="4" width="100%">
          
           <rich:panel style="width:133px">
           <f:facet id="1" name="header">
           <h:outputText value="Source List" />
           </f:facet>
           <h:dataTable id="src" columns="1" value="#{BackingBean.Dto.people}"
           var="fm" footerClass="footerClass">
          
           <h:column>
           <a4j:outputPanel style="width:100px;border:1px solid gray;padding:2px"
           layout="block">
           <rich:dragSupport dragIndicator=":indicator"
           dragType="text" dragValue="#{fm}">
           <rich:dndParam name="label" value="#{fm.lastname}" />
           </rich:dragSupport>
           <h:outputText id="blah14" value="#{fm.lastname}"></h:outputText>
           </a4j:outputPanel>
           </h:column>
           </h:dataTable>
           </rich:panel>
          
           <rich:panel id="blah1" styleClass="dropTargetPanel">
           <f:facet id="2" name="header">
           <h:outputText value="PHP Frameworks" />
           </f:facet>
           <rich:dropSupport id="php" acceptedTypes="text" dropValue="PHP"
           dropListener="#{BackingBean.addPerson}" reRender="phptable">
           </rich:dropSupport>
          
           <h:dataTable id="phptable" columns="1" value="#{BackingBean.Dto.people}" var="fm">
           <h:column>
           <h:outputText id="blah13" value="#{fm.firstname}"></h:outputText>
           </h:column>
           </h:dataTable>
          
           </rich:panel>
           </h:panelGrid>
           </form>


          • 2. Re: duplicate Id for a component _id0 from dnd example
            Nick Belaevski Master

            Hello,

            Can you please add bean code also?

            • 3. Re: duplicate Id for a component _id0 from dnd example
              J D Newbie

              Sure, not sure if it will help any - it's just a managed bean with session scope - here is the method mapped to dropevent:

               public void addPerson(DropEvent event) {
               System.out.println("ADDING CONTACT!");
               getDto().addPerson(new Person("Firstname","Last","test"));
               System.out.println("ADDED CONTACT!");
               System.out.println("SIZE: +getDto().getPeople().size());
               }


              The debugging output to console when I drop items shows the code is correctly incrementing the size count of the list (and as I said, when I do a manual refresh after dropping a few items in IE, I correctly see the updated list contents with the "Firstname Last" names displayed).

              • 4. Re: duplicate Id for a component _id0 from dnd example
                Nick Belaevski Master

                Have you tried using h:form instead of form?

                • 5. Re: duplicate Id for a component _id0 from dnd example
                  J D Newbie

                  Yeah, when I tried h:form got same error behavior but then when I did the manual refresh in IE, I got the error page with the jsf component stacktrace (which I always get in FF, but as I said, in IE when I was using just form and did the manual refresh, the page did correctly show the updated list values I had modified). Not sure if this matters at all, but I've also had to comment out the org.apache.myfaces.webapp.StartupServletContextListener listener-class in web.xml; my app breaks completely when I have both that and richfaces.