3 Replies Latest reply on Sep 25, 2009 6:52 AM by Ilya Shaikovsky

    Duplicate ID in rich:panelMenu

    Ker P Newbie

      Hello

      I have sometimes a problem with duplicate IDs when I create a rich:panelMenu.
      The strange thing is that it happens more or less once per month. The server start the application everyday and it there is no problem most of the time but sometimes (1/30) I have this log :

      [22/09/09 8:48:23:187 CEST] 00000019 lifecycle E JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /pages/private/catalog.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@a200a2]
      [22/09/09 8:48:23:211 CEST] 00000019 servlet E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Exception non interceptée émise par l'une des méthodes de service du servlet Faces Servlet dans l'application MyApiEAR. Exception émise : javax.servlet.ServletException: Attibute "name" with value "1" is already used in PanelMenu. It must be unique for every group/item.
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1455)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1396)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:131)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
      at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:852)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:788)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:444)
      at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
      at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:860)
      at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1566)
      at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:175)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
      at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
      at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:557)
      at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:607)
      at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:984)
      at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1069)
      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
      Caused by: java.lang.RuntimeException: Attibute "name" with value "1" is already used in PanelMenu. It must be unique for every group/item.
      at org.richfaces.renderkit.html.PanelMenuRenderer.insertScript(PanelMenuRenderer.java:191)
      at org.richfaces.renderkit.html.HtmlPanelMenuRenderer.doEncodeEnd(HtmlPanelMenuRenderer.java:278)
      at org.richfaces.renderkit.html.HtmlPanelMenuRenderer.doEncodeEnd(HtmlPanelMenuRenderer.java:289)
      at org.ajax4jsf.renderkit.RendererBase.encodeEnd(RendererBase.java:134)
      at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:850)
      at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:281)
      at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
      at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:220)
      at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:215)
      at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:826)
      at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
      at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:178)
      at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:126)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:826)
      at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
      at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
      at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:220)
      at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:215)
      at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:826)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
      at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:826)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
      at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:289)
      at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:220)
      at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
      at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
      ... 26 more


      This is my .faces code :

      <rich:panelMenu id="panelMenu" binding="#{CatalogBean.panelMenu}">
       </rich:panelMenu>


      And this is the java code in my bean to fill the panelMenu. It is probably not the most *beautifull* code but I don't see why it should not work, the name is incremented each time:

      public void loadMenu (){
       panelMenu = new HtmlPanelMenu();
       panelMenu.setWidth(MyConstants.CATALOG_MENU_WIDTH);
       panelMenu.setMode("ajax");
      
       StringBuilder sb = new StringBuilder();
       List<Category> result = null;
       Session sess = HibernateUtil.getSessionFactory().openSession();
       sb.append("FROM Category");
      
       Query query = sess.createQuery(sb.toString());
      
       result = query.list();
       sess.close();
       long i=0;
       ActionListener menuListener = new MenuListener();
      
       ResourceBundle bundle = ResourceBundle.getBundle(MyConstants.BUNDLE_MESSAGES,FacesContext.getCurrentInstance().getViewRoot().getLocale());
       String all = bundle.getString("All");
       for(Category gr1:result){
      
       i++;
      
       HtmlPanelMenuGroup menuGroup_AccountInfo0 = new HtmlPanelMenuGroup();
       menuGroup_AccountInfo0.setLabel(gr1.getDescription(FacesContext.getCurrentInstance().getViewRoot().getLocale().toString()));
       menuGroup_AccountInfo0.setName(i+"");
       if(selectedCategory.equals(gr1.getId())){
       menuGroup_AccountInfo0.setExpanded(true);
       }
       menuGroup_AccountInfo0.setIconCollapsed("triangle");
       menuGroup_AccountInfo0.setIconExpanded("triangleDown");
      
       List<SubCategory> subCategoryList=new ArrayList<SubCategory>();
      
       subCategoryList=SubCategory.get(gr1.getId());
      
       boolean isFirstSubCategory = true;
       for(SubCategory gr12:subCategoryList){
       if(isFirstSubCategory){
       i++;
       HtmlPanelMenuItem menuItem_AccountInfo = new HtmlPanelMenuItem();
       menuItem_AccountInfo.setLabel(all);
       menuItem_AccountInfo.setName(i+"");
       menuItem_AccountInfo.setMode("ajax");
       menuItem_AccountInfo.setValue(gr1.getId()+"*** *** ");
       menuItem_AccountInfo.addActionListener(menuListener);
       menuGroup_AccountInfo0.getChildren().add(menuItem_AccountInfo);
       isFirstSubCategory = false;
       }
      
       List<SubCategory2> subCategory2List=new ArrayList<SubCategory2>();
      
       HtmlPanelMenuGroup menuGroup_AccountInfo1 = new HtmlPanelMenuGroup();
       menuGroup_AccountInfo1.setLabel(gr12.getDescription(FacesContext.getCurrentInstance().getViewRoot().getLocale().toString()));
       i++;
       menuGroup_AccountInfo1.setName(i+"");
       menuGroup_AccountInfo1.setIconCollapsed("triangle");
       menuGroup_AccountInfo1.setIconExpanded("triangleDown");
       if(selectedSubCategory.equals(gr12.getId()))
       menuGroup_AccountInfo1.setExpanded(true);
      
       subCategory2List=SubCategory2.get(gr12.getId());
       boolean isFirstSubCategory2 = true;
       for(SubCategory2 gr13:subCategory2List){
       if(isFirstSubCategory2){
       i++;
       HtmlPanelMenuItem menuItem_AccountInfo = new HtmlPanelMenuItem();
       menuItem_AccountInfo.setLabel(all);
       menuItem_AccountInfo.setName(i+"");
       menuItem_AccountInfo.setMode("ajax");
       menuItem_AccountInfo.setValue(gr1.getId()+"***"+gr12.getId()+"*** ");
       menuItem_AccountInfo.addActionListener(menuListener);
       menuGroup_AccountInfo1.getChildren().add(menuItem_AccountInfo);
       isFirstSubCategory2 = false;
       }
       i++;
      
       HtmlPanelMenuItem menuItem_AccountInfo = new HtmlPanelMenuItem();
       menuItem_AccountInfo.setLabel(gr13.getDescription(FacesContext.getCurrentInstance().getViewRoot().getLocale().toString()));
       menuItem_AccountInfo.setName(i+"");
       menuItem_AccountInfo.setMode("ajax");
       menuItem_AccountInfo.setValue(gr1.getId()+"***"+ gr12.getId()+"***"+ gr13.getId());
       menuItem_AccountInfo.addActionListener(menuListener);
       menuGroup_AccountInfo1.getChildren().add(menuItem_AccountInfo);
       }
       menuGroup_AccountInfo0.getChildren().add(menuGroup_AccountInfo1);
      
       }
       panelMenu.getChildren().add(menuGroup_AccountInfo0);
       }
       }


      Thank you