5 Replies Latest reply on Jan 16, 2008 6:19 AM by Jane A

    Duplicate Id for components when using Rich context Menu

    Jane A Newbie

      Hi,
      I have downloaded richfaces-3.1.3.GA to implement a right click contextual menu in my application.

      The right click menu is implemented on h:commandLinks which are tree node items. I am using the tomahawk tree component



      
      <t:tree2 id="LeftNavMenuTree"
       value="#{guidelineHierarchyBean.guidelineHierarchy}" var="node"
       varNodeToggler="t" clientSideToggle="false"
       binding="#{guidelineHierarchyBean.tree}" showRootNode="false"
       showNav="false">
      
       <f:facet name="root">
       <h:outputText value="root" />
       </f:facet>
      
       <f:facet name="guideline">
       <enforcement:linkWithRightClick
       menuId="GuidelineMenuId"
       menuIdValue="#{node.pageView.page.pageId}"
       linkText="#{node.pageView.page.pageName}"
       method="#{guidelineEditorBean.deletePage}"
       rendered="#{!node.pageView.selected}"
       selectedProperty="#{guidelineEditorBean.selectedPageView}"
       selectedValue="#{node.pageView}"
       />
       </f:facet>
      
       <f:facet name="page">
      
       <enforcement:linkWithRightClick
       menuId="PageMenuId"
       menuIdValue="#{node.pageView.page.pageId}"
       linkText="#{node.pageView.page.pageName}"
       method="#{guidelineEditorBean.deletePage}"
       rendered="#{!node.pageView.selected}"
       selectedProperty="#{guidelineEditorBean.selectedPageView}"
       selectedValue="#{node.pageView}"
       />
      
      
       </f:facet>
      
       </t:tree2>
      
      
      



      I have implemented the h:commandLink with right click menu as a custom facet component refered to as <enforcement:linkWithRightClick>

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:si="http://sourceforge.net/projects/easysi"
       xmlns:c="http://java.sun.com/jstl/core"
       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:t="http://myfaces.apache.org/tomahawk">
      
      
      
      <ui:composition>
       <script type="text/javascript" src="javascript/confirmDelete.js" />
      
      
       <rich:panel>
      
       <h:commandLink value="#{linkText}" styleClass="#{styleClass}" action="#{guidelineEditorBean.setPage}" >
       <rich:contextMenu event="oncontextmenu" attached="true" submitMode="server">
       <rich:menuItem id="#{menuId}MenuItemDelete#{menuIdValue}"
       immediate="true"
       value="Delete"
       action="#{guidelineEditorBean.deletePage}"
       rendered="#{guidelineEditorBean.pageViewToPaste == null}">
       >
      
       <t:updateActionListener
       property="#{guidelineEditorBean.selectedPageView}"
       value="#{node.pageView}" />
      
       </rich:menuItem>
      
      
       <rich:menuGroup id="#{menuId}MenuGroupAdd#{node.pageView.page.pageId}"
       value="Add Page"
       rendered="#{guidelineEditorBean.pageViewToPaste == null}"
       >
       <rich:menuItem id="#{menuId}MenuItemAddAbove#{node.pageView.page.pageId}" value="Above" action="#{guidelineEditorBean.addPageAbove}"
       rendered="#{guidelineEditorBean.pageViewToPaste == null}">
      
       <t:updateActionListener
       property="#{guidelineEditorBean.selectedPageView}"
       value="#{node.pageView}" />
       </rich:menuItem>
      
       <rich:menuItem
       id="#{menuId}MenuItemAddBelow#{node.pageView.page.pageId}"
       value="Below" action="#{guidelineEditorBean.addPageBelow}"
       rendered="#{guidelineEditorBean.pageViewToPaste == null}">
       <t:updateActionListener
       property="#{guidelineEditorBean.selectedPageView}"
       value="#{node.pageView}" />
       </rich:menuItem>
      
      
       <rich:menuItem
       id="#{menuId}MenuItemAddSub#{node.pageView.page.pageId}"
       value="Sub" action="#{guidelineEditorBean.addSubPage}"
       rendered="#{guidelineEditorBean.pageViewToPaste == null}">
       <t:updateActionListener
       property="#{guidelineEditorBean.selectedPageView}"
       value="#{node.pageView}" />
       </rich:menuItem>
      
       </rich:menuGroup>
      
       <rich:menuItem
       id="#{menuId}MenuItemCut#{menuIdValue}" value="Cut" action="#{guidelineEditorBean.movePage}"
       rendered="#{guidelineEditorBean.pageViewToPaste == null}">
       <t:updateActionListener
       property="#{guidelineEditorBean.pageViewToPaste}"
       value="#{node.pageView}" />
       </rich:menuItem>
      
       <rich:menuItem
       id="#{menuId}MenuItemCopy#{menuIdValue}" value="Copy" action="#{guidelineEditorBean.copyPage}"
       rendered="#{guidelineEditorBean.pageViewToPaste == null}">
       <t:updateActionListener
       property="#{guidelineEditorBean.pageViewToPaste}"
       value="#{node.pageView}" />
       </rich:menuItem>
      
      
       <rich:menuGroup id="#{menuId}MenuGroupPaste#{node.pageView.page.pageId}"
       value="Paste"
       rendered="#{!node.pageView.pasteHidden and guidelineEditorBean.pageViewToPaste != null}"
       >
       <rich:menuItem id="#{menuId}MenuItemPasteAbove#{node.pageView.page.pageId}" value="Above" action="#{guidelineEditorBean.pastePageAbove}"
       rendered="#{!node.pageView.pasteHidden and guidelineEditorBean.pageViewToPaste != null}">
       <t:updateActionListener
       property="#{guidelineEditorBean.selectedPageView}"
       value="#{node.pageView}" />
       </rich:menuItem>
      
       <rich:menuItem
       id="#{menuId}MenuItemPasteBelow#{node.pageView.page.pageId}"
       value="Below" action="#{guidelineEditorBean.pastePageBelow}"
       rendered="#{!node.pageView.pasteHidden and guidelineEditorBean.pageViewToPaste != null}">
       <t:updateActionListener
       property="#{guidelineEditorBean.selectedPageView}"
       value="#{node.pageView}" />
       </rich:menuItem>
      
       <rich:menuItem
       id="#{menuId}MenuItemPasteSub#{node.pageView.page.pageId}"
       value="Sub" action="#{guidelineEditorBean.pastePageAsSubPage}"
       rendered="#{!node.pageView.pasteHidden and guidelineEditorBean.pageViewToPaste != null}">
       <t:updateActionListener
       property="#{guidelineEditorBean.selectedPageView}"
       value="#{node.pageView}" />
       </rich:menuItem>
      
       </rich:menuGroup>
      
       </rich:contextMenu>
       </h:commandLink>
       </rich:panel>
      
      
      </ui:composition>
      
      </html>
      
      



      Whenever some action is triggered by a menu item, i get the error

      duplicate Id for a component j_id28:LeftNavMenuTree:j_id32
      


      and errors similar to that for other components. I have given unique ids to menu items which solved similar problems.


      Can anyone guide me through this ..


      Thnx

      Yogesh


        • 1. Re: Duplicate Id for components when using Rich context Menu
          Nick Belaevski Master

          Could you please check what component has id="j_id32"? You can use ui:debug component to find that out.

          • 2. Re: Duplicate Id for components when using Rich context Menu
            Yogesh Novice

            Hi,
            I have been able to render the tree properly with the rich faces context menu on command links. They render well at first time. However, whenever i click on a menu item and the action is triggered, there seem to be some hazardous behaviour. Sometimes, the correct region of the page is not rendered correctly and other times, the command links in the tree disappear.

            I am using submitMode="server". Is there a tweak for this ?


            Thnx for the help,

            Yogesh

            • 3. Re: Duplicate Id for components when using Rich context Menu
              Ilya Shaikovsky Master

              sorry, and what about scope of your guidelineHierarchyBean?

              • 4. Re: Duplicate Id for components when using Rich context Menu
                Yogesh Novice

                GuidelineHierarchyBean and GuidelineEditorBean are both SFSBs

                • 5. Re: Duplicate Id for components when using Rich context Menu
                  Jane A Newbie

                  My tomahawk tree component is initially rendered properly but after I click a menu item from the contextual menu, I get the following error


                  java.lang.NullPointerException
                   at org.apache.myfaces.custom.tree2.HtmlTreeRenderer.encodeTree(HtmlTreeRenderer.java:281)
                   at org.apache.myfaces.custom.tree2.HtmlTreeRenderer.encodeChildren(HtmlTreeRenderer.java:227)
                   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                   at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                   at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
                   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                   at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
                   at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
                   at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeChildren(AjaxContainerRenderer.java:97)
                   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                   at org.ajax4jsf.component.UIAjaxRegion.encodeChildren(UIAjaxRegion.java:113)
                   at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                   at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
                   at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
                   at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
                   at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
                   at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
                   at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                   at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
                   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                   at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                   at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
                   at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                   at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                   at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
                   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                   at java.lang.Thread.run(Unknown Source)
                  



                  Help plz !


                  Cheers,
                  Yogesh