Version 1

    My problem was to add context menu to the extendedDataTable row with disabled items depending on the selected row. rich:extendedDataTable does not support oncontextmenu event so that I could not use a4j:support with event="oncontextmenu". My solution is:


    h1. 1. Define context menu


    <rich:contextMenu attached="false"




         <rich:menuItem disabled="#{Menu.item1disabled}" value="Item 1"/>

         <rich:menuItem disabled="#{Menu.item2disabled}" value="Item 2"/>



    This is standard contextMenu.


    h1. 2. Define the table


    <rich:extendedDataTable var="r" value="#{data}" id="data">



                   <h:inputHidden id="rowId" value="#{}"/>

                   <h:outputText value="#{r.value1}"/>



    The table does not have context menu attached yet. Notice  <h:inputHidden id="rowId" value="#{}"/>. This element holds the value we will use to identify selected row in the code bellow.


    h1. 3. Rerender function for the menu


    <a4j:jsFunction name="myRowSelect"





         oncomplete="#{rich:component('myContextMenu')}.show(lastEvent, {})">

         <a4j:actionparam name="param1" assignTo="#{Menu.selected}"/>



    This code tells which item is selected and we can render menu for the specified row and then display it.


    h1. 4. Java script to find selected row and rerender menu


    var lastEvent = null;
    function onContextMenu(e) {

      lastEvent = e;

      try {

        // find the row selected and get its "rowId".

        selectedId = (jQuery("tr").find("input:hidden").get()[0].value);

        // rerender the menu a display it


      } catch(ex) {

        alert("Failed: "+ex);


      return false;






    h1. 5. Bind the functions and menu to the table

    {code:xml}<rich:jQuery name="myContextMenuFunc"


         query='bind("contextmenu",function(e) {return onContextMenu(e);})'



    This code binds the context menu (right mouse click in the table) to the table.


    And thats all folks.


    I hope it will help.