Displaying a context menu on right click on rich tree

Please see the code below. I want to display a context menu on right click on a rich tree.
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich">
    <style>
        .col1{ width:50%; vertical-align:top;
    </style>
    <h:form>   
        <h:panelGrid columns="1" width="100%" columnClasses="col1">
             <rich:tree style="width:300px" nodeSelectListener="#{simpleTreeBean.processSelection}"
                switchType="client"
                value="#{simpleTreeBean.treeNode}" var="item" id="item">
                <rich:componentControl event="onClick" for="menu" operation="show">
                <f:param value="#{item.data}" name="send" />
            </rich:componentControl>
            </rich:tree>
            </h:panelGrid>
        <a4j:outputPanel ajaxRendered="true">
            <rich:panel>
                <f:facet name="header">Last Menu Action</f:facet>
                <h:outputText escape="false" value="Right Click :  #{simpleTreeBean.nodeTitle}" id="selectedNode" />
                <br/>
            </rich:panel>      
        </a4j:outputPanel>
             <rich:contextMenu event="oncontextmenu" actionListener="#{SimpleTreeBean.processCurrElement}" attached="true" id="menu" submitMode="ajax">
            <rich:menuItem ajaxSingle="true">
            <b> #{simpleTreeBean.nodeTitle}</b> Send To
                <a4j:actionparam name="det" assignTo="#{ddmenu.current}" value=" #{simpleTreeBean.nodeTitle}"/>
            </rich:menuItem>
        </rich:contextMenu>
    </h:form>
</ui:composition> With this code, i need left click at first then right click, then it will show the selected node. I want to get the value of the node title on right click. Please help me with it. The SimpleTreeBean code:
package com.dW;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.faces.FacesException;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.richfaces.component.UITree;
import org.richfaces.event.NodeSelectedEvent;
import org.richfaces.model.TreeNode;
import org.richfaces.model.TreeNodeImpl;
public class SimpleTreeBean
    private TreeNode rootNode = null;
    private String nodeTitle;
    private static final String DATA_PATH = "images/simpleTreeData.properties";
    private void addNodes(String path, TreeNode node, Properties properties) {
        boolean end = false;
        int counter = 1;
        while (!end) {
            String key = path != null ? path + '.' + counter : String.valueOf(counter);
            String value = properties.getProperty(key);
            if (value != null) {
                TreeNodeImpl nodeImpl = new TreeNodeImpl();
                nodeImpl.setData(value);
                node.addChild(new Integer(counter), nodeImpl);
                addNodes(key, nodeImpl, properties);
                counter++;
            } else {
                end = true; } }  }
    private void loadTree() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExternalContext externalContext = facesContext.getExternalContext();
        InputStream dataStream = externalContext.getResourceAsStream(DATA_PATH);
        try {
            Properties properties = new Properties();
            properties.load(dataStream);
            rootNode = new TreeNodeImpl();
            addNodes(null, rootNode, properties);
        } catch (IOException e) {
            throw new FacesException(e.getMessage(), e);
        } finally {
            if (dataStream != null) {
                try {
                    dataStream.close();
                } catch (IOException e) {
                    externalContext.log(e.getMessage(), e);
    public TreeNode getTreeNode() {
        if (rootNode == null) {
            loadTree();
        return rootNode;
    public void processSelection(NodeSelectedEvent event) {
        UITree tree = (UITree) event.getComponent();
        nodeTitle = (String) tree.getRowData();
    public void processCurrElement(ActionEvent event) {
        UITree tree = (UITree)event.getSource();
        nodeTitle = (String)tree.getRowData();
        System.out.println(nodeTitle);
    public String getNodeTitle() {
        return nodeTitle;
    public void setNodeTitle(String nodeTitle) {
        this.nodeTitle = nodeTitle;
}

Hi,
Do you have a solution for this? Looking for exactly the same.
As far as I have it at the moment I have the backing object added to the attributes of the node:
<a4j:support event="oncontextmenu"
                                     oncomplete="#{rich:component('foldersContextMenu')}.doShow(event, {})"
                                     actionListener="#{customerBean.buildContextMenu}" reRender="foldersContextMenu, selectedNode">
                            <f:setPropertyActionListener value="#{item}" target="#{customerBean.nodeTitle}"/>
                            <f:attribute name="node" value="#{item}"/>
                        </a4j:support>This allows me to get the object in the backing bean:
public void buildContextMenu(ActionEvent event) {
        UIComponent component = event.getComponent();
        log.info("component: " + component.getId());
        Category node = (Category) component.getAttributes().get("node");
        log.debug("node : " + node);But how I translate that to setting this as the current node is causing me problems.
Thanks
Jon

Similar Messages

  • Context menu on right-click

    How can i get a context menu popup when the user right-clicks a table row? Will the conflict with the selection listener? thanks

    [url http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html#popup]Bringing Up a Popup Menu

  • Menu on right-click for numeric control

    Hello,
    is there a way to program a "menu on right-click" for a control (e.g. numeric), like there is for table controls?
    I'm working with CVI 8.0.1 
    Thanks & Best Regards,
    Greg

    Yes, every control can be added a popup menu with a few instructions.
    Design the menu nar in the UIR editor; do not associate it to any panel
    Load the menu bar when needed with the line menuHandle = LoadMenuBar (0, "myfile.uir", menuBar): by passing 0 as the panel handle it will not be associated to any of them
    In the numeric callback add these instructions:
         switch (event) {
            case EVENT_RIGHT_CLICK:
                // Context menu
               choice = RunPopupMenu (menuHandle, menuBar_Menu, panel, eventData1, eventData2, 0, 0, 0, 0);
                switch (choice) {
                     case menuBar_menu_item1:
                              // menu item handling code
                              break;
                break;
    Passing eventData parameters to RunPopupMenu function ensures that the menu is displayed at the mouse position.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Pop up menu on right clicking an image?

    Hello,
    I am new to LabWindows/CVI. 
    Requirement: "To get a pop-up menu on right clicking on image"
    Right now, I display my images in window numbers (0 - 15). Is it possible to be able to get a pop-up menu on right clicking an image window. If yes, how? If not, could you please suggest other methods to achieve this task? Should I display the image in a separate parent panel for example? How could I do this?
    Any help would be great.
    Cheers

    I would use the code generator for right click event. then fill it up with whatever code you want under right click case. You can access these when you double click your UIR file, then on the top of the page click Code\Preferences\Default... then choose desired events for picture then go to Code\Generate\all callbacks and skip through the ones you don't want to be replaced.

  • JSF Popup Menu on right click

    Hi ,
    I want to popup menu on right click of any component(say tree).I searched on the net and found the tomahawk <t:popup> component.
    This component popup the menu when mouse pointer enter in to the component but I don't want this behavior.
    I want to popup the menu only when I right click on the component.
    This is sample program
    <t:popup id="a"
    styleClass="popup"
    closePopupOnExitingElement="true"
    closePopupOnExitingPopup="true"
    displayAtDistanceX="10"
    displayAtDistanceY="10" >
    <h:outputText id="oa" value="#{country.name}"/>
    <f:facet name="popup">
    <h:panelGroup>
    <h:panelGrid columns="1" >
    <h:outputText value="#{country.cities}"/>
    </h:panelGrid>
    </h:panelGroup>
    </f:facet>
    </t:popup>
    DO you have any component like this ? Or any other way to do like this ?
    Thanks in Advance,
    KK

    I wrote a component a while back that does something similar to what you want. You'd probably need to fix it up and add any features that you need that it doesn't already have. It pops up a menu on a right-click, it allows you to provide a facet to supply the contents of the menu. I doubt I made sure it works in IE or any browser other than Firefox... so there may be JS issues. It has some other component dependencies you might want to remove also. I could get it to the point where you could try it out and fix it up if you want, but I won't have time until next week.
    Ken Paulsen
    https://jsftemplating.dev.java.net

  • "Toast it" appearing in menu when right clicking

    The words "Toast it" appears in menu when right clicking an icon but Toast has been uninstalled. How can I remove it please?

    Try this previous discussion:
    https://discussions.apple.com/message/12533120#12533120
    Re: "Toast It" wont go from contextual menu

  • Context Menu on the right click of af:tree node

    Hi Experts,
    I am using drag and drop functionality in af:tree.In that i used one tree for drag source and another one tree for drop target,and it is working as expected.
    Now I want to bring one additional option in the context menu of the target tree node that is ,when i right click on any of the target tree node in addition to the default menu options like "Collapse","Expand" i want to add one more option .For this i added "contextMenu" facet after the "nodeStamp" facet inside the tree.
    *<f:facet name="contextMenu">*
    *<af:popup id="p1">*
    *<af:menu text="Delete" id="m1">*
    *<af:commandMenuItem text="Delete" id="cmi1"*
    *action="#{myWorkflow.deleteWorkflowNode}"/>*
    *</af:menu>*
    *</af:popup>*
    *</f:facet*>
    Now the problem is : before using drag and drop the context menu workes without any problem .But after using drag and drop the context menu is not popped up.
    can anybody help me to resolve this?
    Thanks,
    Priya.

    Hi Frank,
    1. I am using JDeveloper 11.1.1.3 version
    2. Drop target tree is having the context menu.
    3. Yes . In Drop event am calling a backing bean method with return type DnDAction and i return the value as DnDAction.MOVE to reflect the changes in the database table to the target tree.
    Regards,
    Priya.

  • Context Menu (or right button click) does not appear menu-window

    The context menu does not appear in some browser sections.
    If I run browser in safe mode it works without problem.
    I've tried to reinstall firefox, after uninstall I also manualy deleted all rest hidden and visible folders - did not help.
    Also I tried restore to default mode - did not help.
    Here I put screenshoot.
    Regards.
    //sorry for my eng

    Yes, it helped. Thank you very much!
    Kind regards.

  • How to get a pop-up menu on right click of JTree?

    hi
    My application consists of a JTree.I am having a 2 root nodes each one have some child nodes.in the first root node what i want is on right click of child node i have to display one option that is enabled and on the second root node what i want is on right click of child node i have to display one option that is disabled..
    how to do that
    thanks for your reply in advance,

    When you are creating your nodes, do node.setUserObject(objectName);
    and on right click, do something like this
    if (e.isPopupTrigger() == true) {
             selPath = tree.getPathForLocation(e.getX(), e.getY());
          try {
             // If Right Click, Select the Node
             Object[] selectedPath = selPath.getPath();
             DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) selectedPath[selectedPath.length - 1];
             try {
                dataObject = (MyObject) selectedNode.getUserObject(); // Set the Data Object
             } catch (ClassCastException ex) {
                                      ex.printStackTrace();
             // Check for the right click on Framework Node
             if (dataObject.getClass().isInstance(new MyObject()) == true) {
                // Disable the pop-up menu
    ....

  • Popup menu with right-click

    I am investigating the feasibility of adding "Personalised Menu"
    functionality to a Forms application. The idea is that regardless
    of what form a user is currently in, he/she will be able
    to right click on the canvas to display a list of "favourite screens".
    Next, s/he will pick a screen from this list and hey presto will
    be navigated to it. There will need to be "Do you want to save
    your changes?" processing of course before hopping to the new screen.
    When the user right-clicks s/he should see a customised list of menu options:
    user "Peter" could have e.g. a menu with options "Screen A", "Screen C", "Screen D";
    user "Paul" could have screens E,F,G,J on his list and "Mary" could have
    screens A,B,K,Q,R. There will be companion admin functionality to allow
    users to maintain the options they want on their personalised menus but
    this is easy to code using standard forms functionality.
    To simulate the functionality I have created a little PERSMENU form
    to display the user's personalised list of screens on a standard
    multi-row block.
    This is executed via a CALL_FORM in the PRE-POPUP-MENU trigger.
    Of course if I use a called form to display the menu options then
    I need to check if the calling form has any unsaved changes beforehand.
    Which is a bit clunky.
    Another alternative would be to add a PERSMENU block to each form
    in the application. If the user were to right-click on a form's canvas
    the form would attempt to navigate to PERSMENU and then execute_query.
    But of course WHEN-VALIDATE-ITEM triggers etc could prevent the navigation
    and once again the proposal is a bit clunky.
    I have been reading the "Popup menu with left click on 10g" thread at
    Popup menu with left click on 10g
    and am interested in the javabean provided by "Nalin R". Unfortunately
    I am new to java and don't understand the code. But this looks to be
    tantalisingly close to what I am trying to do albeit with "left-click"
    rather than "right-click".
    Has anyone attempted anything similar? Am I right in thinking that the
    javabean approach offers the best solution and if so is there any
    sample code that would help?

    ( (BasicInternalFrameUI)internalFrame.getUI() ).getNorthPane().addMouseListener( new MouseListener(){
    public void mouseClicked( MouseEvent me ){
    //do what ever you want
    });

  • Labview edit time menu and right click popup menus

    How can i add a menu item to the labview edit time menus and to the right click popup menu of any selected object in a block diagram?
    I would like to integrate commonly used tools by me out of the springboard scripting tool into actual labview.
    Solved!
    Go to Solution.

    It sounds to me like you are looking for something like the Right-Click Framework.  Some people really like it, I have not used it extensively myself.  I've had a request to convert a quick drop shortcut into a RCF plug-in, I'll see how it goes.  I have also longed for a good way to hook into the LV IDE to add my own tools, what I find are useful, but not fully satisfactory solutions.
    1)  Right-Click Framework:  Some initial startup costs in terms of downloading and installing.  Start up is a bit slow (on my machine), and the workflow is a bit different than what I am used to:  Select an object, press the hotkey, right-click.  You can get used to it, but it is not as responsive as a built-in right-click since you can't right-click in one action.  It seems to be easily extensible, I'll know more in a day or two.
    2)  Quick Drop:  Built into LV.  Slow startup like RCF.  Fairly easily extensible.  Not context aware (unless you build it in to your plug-in), so you have to choose your letters wisely.  After the initial pain, the response time is not shabby, does require the extra Ctrl-Space action.  
    3)  Tools Menu:  I drop a few things in here, like my custom connector pane editor.  Not bad, but there are no keyboard shortcuts (what a pain), so it is good for actions that you might call once or twice on a given VI.
    In short, all of these methods require extra clicks or keypresses and are a bit sluggish.  If something like copy and paste behaved this way we would never use LV again, but if your tool truly saves you a bunch of steps it is well worth it.  I have almost run out of letters to use for my QD shortcuts.
    Addedendum:  Personally I am not quite ready to start talking to my computer, but LVSpeak seems pretty cool, Smashy Smashy.

  • Context Menu and DrillDownSubreport Click event

    I have developed my application using Crystal Reports 2008 and C#. My form embeds a Crystal ReportViewer for user to view our custom reports. We also include a popup context menu on the GUI but we experience problems with the built-in DrillDownSubreport behavior. When we launch (right click) the context menu on top of the report content page and click any of the menu item, the mouse click seems to trigger the DrillDownSubreport at the same time. I had tried to mask that but wasn't successful - e.g. using context menu popup and collapse event to set different DrillDownSubreport handler on setting the return value (true to disabled) as well as trying on the WndProc.
    I would appreciate if someone can help me to resolve this issue so that my context menu will work without triggering the subreport drilldowns.
    Thanks in advance.

    Hello,
    Have you tried to cancel drilldown on the Crystal Reports Viewer? Be aware, it will cancel all drilldown not just subreports.
    CrystalReportViewer1.EnableDrillDown = False
    'Set the viewer to the report object
    CrystalReportViewer1.ReportSource = crReportDocument
    Elaine

  • Adobe Reader LE 2.5 in HTC Touch HD has no reflow options in the menu or right click document options

    Adobe LE 2.5 bundled with HTC Touch HD does not show reflow option in the menu at the bottum or the right click options over the document.
    Can any one help please

    I found thw solution in xda developers site
    http://forum.xda-developers.com/showthread.php?p=3109636#post3109636

  • Request Membership is display in context menu aber this is not active!

    Hello there,
    I've created a Room(Restricted Room).(with the Administrator role)
    I logged on as Enduser.
    I can see all of the existing Rooms in Room directory.
    I try to request membership to one of the rooms(all the existing Rooms are Restricted).
    I see in contextmenu request membership, but this is not active!
    Have someone please an idea, how can i solve this?
    configuration issue???
    Thanks in advance
    best regards
    Katayoun

    Hi Robert,
    Portal Version is NW04s and SPS 14.
    And light Room Directory is active.
    I've tested, with annd without Light Room Directory, Context menu displayed Request Membership but not active!
    hope, Everyone hat an IDEA!
    Thanks in advance
    Katayoun

  • Application Key (Menu Key) (Right Click Button)

    Hi,
    I have an HP Pavillon Notebook 13-b200nt model. But the notebook doesn't have "application (menu) key which is used instead of right click of mouse.
    Is it possible to change any key function as rihgt click option? Or as far as i know "shift + F10" is a short cut of right click, may i create another short cut?
    Thanks in advance,

    Hi there @Memo1 
    Welcome to the HP Support Forums! It is a great place to find the help you need, both from other users, HP experts and other support personnel.
    There are several different keyboard mapping tools available on the internet. A quick google search will find several that you can investigate.
    Malygris1
    I work on behalf of HP
    Please click Accept as Solution if you feel my post solved your issue, it will help others find the solution.
    Click Kudos Thumbs Up on the right to say “Thanks” for helping!

Maybe you are looking for

  • Using TextSnapshot class on a loaded SWF on an iPad

    Hello, I am creating an iPad app. I am loading SWF files using a Loader object, then placing them in a movieclip and setting a SWFLoaders source property to this clip. Before I add the clip to the SWFLoader control I am using the TextSnapshot class o

  • Report an app that doesn't work

    Can someone please tell me how to report an app that doesn't work and get a refund? The app won't allow feedback (as soon as you type anything the "Submit" button is disabled) and the link for its support goes to a web site that appears to be totally

  • How to attach Item LOV to new Customized form.

    Is it possible to attach Item Lov to new customized form in EBS12.04. For example I have created new form and i want to attach LOV of Item like in Requisition Form a LOV attached with Item Text Box.

  • Automator & podcast - but with a twist

    So, here goes. Every day, numerous small audio segments, from 5 seconds to 2 minutes long, get delivered to a particular gmail account as attachments, each a single attachment to an individual email. They are then routed to a mailbox on my mac. I nee

  • No save button for workset

    Hi, When moving items up or down in the navigation of a workset, the save button remains greyed.  However, if you make a change and close and reopen the workset the changes are there.  This can be bad if you make an inadvertent change without knowing