Duplicate Id for components when using Rich context Menu
jbossja Jan 15, 2008 1:58 AMHi,
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