13 Replies Latest reply on Dec 31, 2005 8:57 PM by gavin.king

    Duplicated id in Faces tree problem

    lcoetzee

      HI all,

      I use the following extensively in a lot of my view pages :

      <h:dataTable value="#{allPortalUsers}" var="currentUser"
       rendered="#{not empty allPortalUsers}">
       <h:column>
       <f:facet name="header0">Name</f:facet>
       #{currentUser.login}
       </h:column>
       <h:column>
       <f:facet name="header2">Edit</f:facet>
       <h:commandLink action="#{portalUserList.selectPortalUser}">Edit user</h:commandLink>
       </h:column>
      </h:dataTable>
      


      linked to
      @DataModel
      private List<PortalUser> allPortalUsers;
      @DataModelSelectionIndex
      private int selectedPortalUserIndex;
      
      in my ActionHandler.

      This works well all over the place except on one page where I get the following error when executing the commandLink:
       [STDOUT] 2005/10/06 11:18:29 com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View
      java.lang.IllegalStateException: Client-id : _id0 is duplicated in the faces tree.
      at org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:241)
      at org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:255)
      at org.apache.myfaces.application.jsp.JspStateManagerImpl.saveSerializedView(JspStateManagerImpl.java:204)
      at com.sun.facelets.FaceletViewHandler.writeState(FaceletViewHandler.java:589)
      at org.apache.myfaces.renderkit.html.HtmlFormRendererBase.encodeBegin(HtmlFormRendererBase.java:74)
      at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:307)
      at com.sun.facelets.FaceletViewHandler.encodeRecursive(FaceletViewHandler.java:511)
      at com.sun.facelets.FaceletViewHandler.encodeRecursive(FaceletViewHandler.java:518)
      at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:447)
      at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:300)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:95)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(Unknown Source)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:157)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Thread.java:595)
      


      I am at a complete loss of where this _id0 is and how to fix this. I have added explicit id's to the components, but it did not make a difference.

      I get the following warning when this page is initially shown.

      INFO [[/tryseam]] WARNING: Component _id0 just got an automatic id, because there was no id assigned yet. If this component was created dynamically (i.e. not by a JSP tag) you should assign it an explicit static id or assign it the id you get from the createUniqueId from the current UIViewRoot component right after creation!
      



      Any suggestions ?

      Thanks

      Louis


        • 1. Re: Duplicated id in Faces tree problem
          gavin.king

          Dunno, its a pure JSF issue by the looks. Maybe Jacob can help.

          • 2. Re: Duplicated id in Faces tree problem

            There are known problems with MyFaces 1.1, you might want to use MyFaces 1.0.9 in the interim.

            • 3. Re: Duplicated id in Faces tree problem
              lcoetzee

              I tried the 1.0.9. No luck.

              In the end I changed my bean from Stateless to Stateful with a defined Conversation scope including Conversation Begin and End boundaries and suddenly everything started to work like a dream (the other beans where I used it are also stateful with a defined conversation).

              Does this mean that the @DataModel and @DataModelSelectionIndex tags only works within a conversation ?



              Louis

              • 4. Re: Duplicated id in Faces tree problem
                gavin.king

                Yes, the DataModel is stored in the conversation scope. Otherwise it would not be there for the next request.

                • 5. Re: Duplicated id in Faces tree problem
                  lcoetzee

                  My mistake... If I only RTFM-ed ;-)

                  Says the following very clearly in the documentation:


                  The following annotations make it easy to implement clickable lists backed by a stateful session bean.


                  And obviously they include the mentioned ones !


                  I assume then for normal Stateless beans one has to use the binding attribute associated with a UIData type ?

                  Thanks

                  Louis


                  • 6. Re: Duplicated id in Faces tree problem
                    marobashi

                    I'm receiving the same error... I also tried using the MyFaces1.0.9 jar in my build, and that didn't solve the issue. The bean I'm working with is already a stateful conversational bean, with @Begin demarcations (the @End demarcations will appear in a separate bean...)

                    Here's the action bean:


                    @Stateful
                    @Name("allItineraries")
                    @Interceptor(SeamInterceptor.class)
                    @Conversational(ifNotBegunOutcome="main")
                    @LoggedIn
                    public class AllItinerariesAction implements AllItineraries, Serializable
                    {
                    private static final Logger log = Logger.getLogger(AllItineraries.class);

                    @PersistenceContext(type=EXTENDED)
                    private EntityManager em;

                    private String searchString;

                    @DataModel
                    private List<Itinerary> itineraries;
                    @DataModelSelectionIndex
                    private int itineraryIndex;


                    @In(required=false)
                    @Out(required=false)
                    @Valid
                    private Itinerary itinerary;

                    @In(required=false)
                    @Out(required=false)
                    private GregorianCalendar workweekenddate;

                    @In
                    private User user;

                    @In
                    private transient FacesContext facesContext;

                    private GregorianCalendar getCurrentWED() {
                    GregorianCalendar gc = new GregorianCalendar();
                    int dow = gc.get(GregorianCalendar.DAY_OF_WEEK);
                    switch (dow) {
                    case GregorianCalendar.SUNDAY:
                    log.info("Sunday");
                    //Already Sunday, is ok.
                    break;
                    case GregorianCalendar.MONDAY:
                    log.info("Monday");
                    gc.add(GregorianCalendar.DAY_OF_MONTH,6);
                    break;
                    case GregorianCalendar.TUESDAY:
                    log.info("Tuesday");
                    gc.add(GregorianCalendar.DAY_OF_MONTH,5);
                    break;
                    case GregorianCalendar.WEDNESDAY:
                    log.info("Wednesday");
                    gc.add(GregorianCalendar.DAY_OF_MONTH,4);
                    break;
                    case GregorianCalendar.THURSDAY:
                    log.info("Thursday");
                    gc.add(GregorianCalendar.DAY_OF_MONTH,3);
                    break;
                    case GregorianCalendar.FRIDAY:
                    log.info("Friday");
                    gc.add(GregorianCalendar.DAY_OF_MONTH,2);
                    break;
                    case GregorianCalendar.SATURDAY:
                    log.info("Saturday");
                    gc.add(GregorianCalendar.DAY_OF_MONTH,1);
                    break;
                    }
                    return gc;
                    }

                    public String getWorkweekenddate() {
                    SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd yyyy");
                    return formatter.format(workweekenddate.getTime());
                    }

                    @Begin
                    public String findCurrent() {
                    itinerary = null;
                    log.info("Begin, itinerary is nulled out.");
                    workweekenddate = getCurrentWED();
                    log.info(workweekenddate.toString());
                    return find();
                    }

                    public String showNext() {
                    workweekenddate = getCurrentWED();
                    workweekenddate.add(GregorianCalendar.DAY_OF_MONTH,7);
                    return find();
                    }

                    public String showLast() {
                    workweekenddate = getCurrentWED();
                    workweekenddate.add(GregorianCalendar.DAY_OF_MONTH,-7);
                    return find();
                    }

                    private String find()
                    {
                    log.info("building itineraries list");
                    itineraries = em.createQuery("from Itinerary where weekenddate like :wed")
                    .setParameter("wed", DateFormat.getDateInstance(DateFormat.SHORT).format(workweekenddate.getTime()))
                    .getResultList();

                    log.info(itineraries.size() + " itineraries found");
                    return "all";
                    }

                    @Destroy @Remove
                    public void destroy() {
                    log.info("destroyed");
                    }

                    }


                    And here's the view that's using it.


                    <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                    xmlns:ui="http://java.sun.com/jsf/facelets"
                    xmlns:h="http://java.sun.com/jsf/html"
                    xmlns:f="http://java.sun.com/jsf/core"
                    template="template2.xhtml">

                    <!-- content -->
                    <ui:define name="content">
                    <div class="section">
                    <h1>Viewing All Users' Itineraries for week ending:</h1>
                    <h:outputText value="#{allItineraries.workweekenddate}"/>
                    <h:form>
                    <fieldset>
                    <h:commandButton value="Previous Week" action="#{allItineraries.showLast}" styleClass="button" /> 
                    <h:commandButton value="Next Week" action="#{allItineraries.showNext}" styleClass="button" /> 
                    <h:commandButton value="Who's missing?" action="butt" styleClass="button" rendered="#{user.administrator}"/> 
                    </fieldset>
                    </h:form>
                    </div>
                    <div class="section">
                    <h:outputText value="No Itineraries Found" rendered="#{itineraries != null and empty itineraries}"/>
                    <h:dataTable value="#{itineraries}" var="its" rendered="#{not empty itineraries}">
                    <h:column>
                    <f:facet name="header">User</f:facet>
                    #{its.user.last}, #{its.user.first}
                    </h:column>
                    <h:column>
                    <f:facet name="header">Monday</f:facet>
                    #{its.monwhere}- #{its.monnotes}
                    </h:column>
                    <h:column>
                    <f:facet name="header">Tuesday</f:facet>
                    #{its.tuewhere}- #{its.tuenotes}
                    </h:column>
                    <h:column>
                    <f:facet name="header">Wednesday</f:facet>
                    #{its.wedwhere}- #{its.wednotes}
                    </h:column>
                    <h:column>
                    <f:facet name="header">Thursday</f:facet>
                    #{its.thuwhere}- #{its.thunotes}
                    </h:column>
                    <h:column>
                    <f:facet name="header">Friday</f:facet>
                    #{its.friwhere}- #{its.frinotes}
                    </h:column>
                    <h:column>
                    <f:facet name="header">Saturday</f:facet>
                    #{its.satwhere}- #{its.satnotes}
                    </h:column>
                    <h:column>
                    <f:facet name="header">Sunday</f:facet>
                    #{its.sunwhere}- #{its.sunnotes}
                    </h:column>
                    </h:dataTable>
                    </div>
                    <div class="section">
                    <h1>Administer your itinerary</h1>
                    <h:form>
                    <fieldset>
                    <h:commandButton value="Find Existing Bookings" action="butt" styleClass="button" />
                    </fieldset>
                    </h:form>
                    </div>
                    </ui:define>

                    </ui:composition>


                    Basically, the problem occurs like this: I start the application, successfully register a new user and log in. I get the main page, which contains a button which links to allItineraries.findCurrent.

                    The page successfully loads, but when I attempt to click either the "Next Week" or "Previous Week" buttons, I receive the following:


                    10:00:33,625 INFO [AllItineraries] Begin, itinerary is nulled out.
                    10:00:33,625 INFO [AllItineraries] Wednesday
                    10:00:33,625 INFO [AllItineraries] java.util.GregorianCalendar[time=1133708433625,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/New_York",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=3,startDay=1,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2005,MONTH=11,WEEK_OF_YEAR=50,WEEK_OF_MONTH=2,DAY_OF_MONTH=4,DAY_OF_YEAR=338,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=10,HOUR_OF_DAY=10,MINUTE=0,SECOND=33,MILLISECOND=625,ZONE_OFFSET=-18000000,DST_OFFSET=0]
                    10:00:33,625 INFO [AllItineraries] building itineraries list
                    10:00:33,640 INFO [AllItineraries] 0 itineraries found
                    10:00:33,968 INFO [[/seam-itinerary]] WARNING: Component _id36 just got an automatic id, because there was no id assigned yet. If this component was created dynamically (i.e. not by a JSP tag) you should assign it an explicit static id or assign it the id you get from the createUniqueId from the current UIViewRoot component right after creation!
                    10:00:34,796 INFO [[/seam-itinerary]] WARNING: Component _id0 just got an automatic id, because there was no id assigned yet. If this component was created dynamically (i.e. not by a JSP tag) you should assign it an explicit static id or assign it the id you get from the createUniqueId from the current UIViewRoot component right after creation!
                    10:00:34,796 INFO [LoggedInInterceptor] User is already logged in
                    10:00:34,812 INFO [AllItineraries] Wednesday
                    10:00:34,812 INFO [AllItineraries] building itineraries list
                    10:00:34,812 INFO [AllItineraries] 0 itineraries found
                    10:00:34,843 INFO [STDOUT] Nov 30, 2005 10:00:34 AM com.sun.facelets.FaceletViewHandler handleRenderException
                    SEVERE: Error Rendering View
                    java.lang.IllegalStateException: Client-id : _id0 is duplicated in the faces tree.
                    at org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:241)
                    at org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:255)
                    at org.apache.myfaces.application.jsp.JspStateManagerImpl.saveSerializedView(JspStateManagerImpl.java:204)
                    at com.sun.facelets.FaceletViewHandler.writeState(FaceletViewHandler.java:589)
                    at org.apache.myfaces.renderkit.html.HtmlFormRendererBase.encodeBegin(HtmlFormRendererBase.java:74)
                    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:307)
                    at com.sun.facelets.FaceletViewHandler.encodeRecursive(FaceletViewHandler.java:511)
                    at com.sun.facelets.FaceletViewHandler.encodeRecursive(FaceletViewHandler.java:518)
                    at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:447)
                    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:300)
                    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:95)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                    at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
                    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
                    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
                    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
                    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                    at java.lang.Thread.run(Thread.java:595)
                    10:00:34,843 INFO [STDOUT] Nov 30, 2005 10:00:34 AM com.sun.facelets.FaceletViewHandler handleRenderException
                    SEVERE: Took Type: org.apache.catalina.connector.CoyoteWriter


                    I admit a modicum of ignorance here... can a DataModel be "reloaded" with new data within the same session/conversation? Perhaps what I'm trying here is just inherently flawed.

                    I appreciate any assistance.

                    • 7. Re: Duplicated id in Faces tree problem
                      marobashi

                      I should say that when I click Next Week / Previous Week I get the severe Error rendering view... I included some of the prior messages to show more of the application "trail".

                      • 8. Re: Duplicated id in Faces tree problem
                        theute

                        Which version of JBoss Seam ? 1.0Beta or CVS HEAD ?
                        Which version of JSF ?
                        I saw that before but with MyFaces 1.1

                        • 9. Re: Duplicated id in Faces tree problem
                          marobashi

                          I'm using everything as packaged by the jboss Seam 1.0 beta1 file.
                          I've attempted to copy my xhtml views from the booking example. Also, when you ask what version of myfaces, do you mean what jar am I using to build the project, or is the myfaces.jar somewhere else in the application / server that I need to look for?

                          Also, I'm deployed on 4.0.3Sp1.

                          I have little if any experience with CVS... I've tried to use it through Eclipse, but either our corp. firewall is blocking me or I'm not configuring it properly.

                          Are there any file snippets I could send that would help answer any questions? (I don't necessarily know where to look for some of this stuff yet... still learning.)

                          Thanks,

                          • 10. Re: Duplicated id in Faces tree problem
                            marobashi

                            Well, I started developing another segment of the application and noticed that my problem seems to be whenever I try to use a variable that I've scoped to the conversation, I get an error.

                            Perhaps before it was trying to start too many conversations, and maybe now the conversation isn't started at all?

                            At this point, I'm going to verify that all of my config files match the booking example, and I'm going to grab the CVS version of seam and work from there. Also, I am going to try to embed some code to check my conversation context and make sure it's not null or empty.

                            Hopefully these steps will help to alleviate my issues.

                            Everything else "seams" to be working great -- I have a user registration, login, logout, change password, and update user information that all work flawlessly. I've just hosed something up about my conversational beans... but I'll defer any log posting for now.

                            • 11. Re: Duplicated id in Faces tree problem
                              andyd

                              Maybe I got the wrong end of the stick, but shouldn't @Begin and @End be on the same bean? I was under the impression that the been is the scope of the conversation, how otherwise would state be transfered between beans?

                              • 12. Re: Duplicated id in Faces tree problem
                                gavin.king

                                They don't have to be; Seam supports propagating conversations across components. But, it is almost certainly better if they are ;)

                                • 13. Re: Duplicated id in Faces tree problem
                                  gavin.king