This content has been marked as final.
Show 4 replies
-
1. Re: contextMenu in treeNode don't select node in 3.3.0
nbelaevski Jan 14, 2009 9:18 AM (in response to alespio)Hello,
Yes, we've fixed bug in rich:contextMenu, that's why events are no more propagating to rich:tree. Check this code:<script>//<![CDATA[ function setSelection(e) { var elt = Event.element(e); //find component and toggle selection var treeItem = Tree.Item.findComponent(elt); if (treeItem.tree.selectionManager.activeItem != treeItem) { treeItem.toggleSelection(e); //create a copy of event for further usage //we'll need it to position context menu window.contextMenuEventCopy = Object.clone(e); } else { showMenu(e); } } function showMenu(e) { #{rich:component('cmenu')}.show(e, {}); } //]]></script> <rich:tree switchType="ajax" value="#{library.data}" var="item" nodeFace="#{item.type}" ajaxSubmitSelection="true" nodeSelectListener="#{requestTestBean.processNodeSelection}" oncomplete="if (event[Richfaces.TreeSelectEvent] && event.originatingEventType == 'contextmenu') { showMenu(window.contextMenuEventCopy); }" > <rich:treeNode oncontextmenu="setSelection(event)" type="artist" iconLeaf="/images/tree/singer.gif" icon="/images/tree/singer.gif"> <h:outputText value="#{item.name}" /> </rich:treeNode> <rich:treeNode oncontextmenu="setSelection(event)" type="album" iconLeaf="/images/tree/disc.gif" icon="/images/tree/disc.gif"> <h:outputText value="#{item.title}" /> </rich:treeNode> <rich:treeNode oncontextmenu="setSelection(event)" type="song" iconLeaf="/images/tree/song.gif" icon="/images/tree/song.gif"> <h:outputText value="#{item.title}" /> </rich:treeNode> </rich:tree> <h:panelGroup id="menu"> <rich:contextMenu id="cmenu" attached="false" submitMode="ajax"> <rich:menuItem value="Menu #{counter}" limitToList="true" reRender="ModalPanelDeleteElement" /> </rich:contextMenu> </h:panelGroup> </h:form>
-
2. Re: contextMenu in treeNode don't select node in 3.3.0
alespio Jan 14, 2009 10:19 AM (in response to alespio)Thanks nbelaevski,
but I've got 2 problem:
1) I cannot insert "#{rich:component..." outside jsf tags (I'm using jsf RI 1.2).
2) According your sample, first right click do selection, and then we need another right click to show contextmenu. It's correct?
There's no other way to propagate right click event to rich:tree?
Thanks -
3. Re: contextMenu in treeNode don't select node in 3.3.0
alespio Jan 14, 2009 12:02 PM (in response to alespio)I've found a workaround:
<script language="javascript"> function setSelection(e) { var elt = Event.element(e); while (elt && !elt.object) { elt = elt.parentNode; } elt.object.toggleSelection(e); Event.stop(e); } </script> ... <rich:menuItem onselect="setSelection(event)" ... />
That's a trick, but, imho, should be naturally that a contextMenu on a treeNode select node automatically. Every application work so.
May be in a future release?
Thanks. -
4. Re: contextMenu in treeNode don't select node in 3.3.0
nbelaevski Jan 14, 2009 7:51 PM (in response to alespio)I've filed RFC: https://jira.jboss.org/jira/browse/RF-5746