Context menu for <p:tree> with Javascript does not work

UI Components for JSF
Post Reply
User avatar
gjegadesh
Posts: 27
Joined: 05 May 2010, 22:17

28 Jun 2010, 16:45

Hi All,

I am trying to implement a context menu for <p:tree> with Javascript as shown below, but the context menu would not pop up for me. I only see the standard, browser's context menu (with Reload, Back, Bookmark, etc.) upon right clicking. Could someone please point out my error? Thanks!

My tree is like this:

Code: Select all

	<p:layoutUnit position="left" width="275" resizable="true" >
            <h:form>
                <p:tree value="#{treeBean.root}" var="node"
                    selection="#{treeBean.selectedNodes}"
                    selectionMode="checkbox"
                    widgetVar="conTree" id="myTree">
                    <p:treeNode>
                            <h:outputText value="#{node}" />
                    </p:treeNode>
                </p:tree>
            </h:form>
	</p:layoutUnit>
And my context menu code in Javascript:

Code: Select all

            function onTriggerContextMenu(p_oEvent) 
            {
                var oTarget = this.contextEventTarget;
                var oCurrentNode = conTree.getNodeByElement(oTarget);

                if (!oCurrentNode) {this.cancel(); }
            }

            var oContextMenu = new YAHOO.widget.ContextMenu(
                "mytreecontextmenu",
                {
                    trigger: "conTree",
                    lazyload: true,
                    itemdata: [
                        { text: "Delete", onclick: { fn: callbackFunction } }
                    ]
                }
            );

            oContextMenu.subscribe("triggerContextMenu", onTriggerContextMenu);

            function callbackFunction() {
                alert('callback called.');
            }
PrimeFaces V2.1, GlassFish 3.0.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 53 guests