title: invoke primefaces context menu from java script
body: <p>i have a svg on my webpage. The elements when right clicked on should display a context menu with data fetched from the database. 
  The elements are written in such a way that the right click event triggers a js function on the page. And i  need to invoke the context menu from the java script. Can someone please help me with this. I have been stuck with this issue for almost 3 days.
  The element :</p>
  
  <pre><code>&lt;rect/&gt;&lt;text&gt;L&lt;/text&gt;&lt;/g&gt;&lt;g id="118" onmousedown="RightClickExecute(event,118)"&gt;
  </code></pre>
  
  <p>java script :</p>
  
  <pre><code>function RightClickExecute(event, id) {
     if (event.button == 2) {document.getElementById("myForm:selectedEntityid").value = id;
        document.getElementById("myForm:selectedObjectType").value = 'Entity';
        document.getElementById("myForm:RightAction").click();
     }
  }
  function showContextMenu(){                                  
     document.getElementById("myForm:contextMenuItemId").click();
   }
  </code></pre>
  
  <p>XHTML:</p>
  
  <pre><code>&lt;p:contextMenu id="contextMenuId" for="svgContainerPanel"
                  widgetVar="contextMenuVar" rendered="#{myBean.objectType=='Entity' ? true : false}"&gt;
                  &lt;p:menuitem id="contextMenuItemId" &gt;&lt;/p:menuitem&gt;
  &lt;/p:contextMenu&gt;
  
  &lt;p:contextMenu event="click" id="contextMenu2Id" for="contextMenuId"
                  widgetVar="contextMenu2Var" model="#{my.model}" &gt;
  
                  &lt;/p:contextMenu&gt;
  
  &lt;p:commandButton id="RightAction" style="visibility:hidden"
                  action="#{myBean.populateMenu}" ajax="true"
                  type="submit" oncomplete="showContextMenu()"
                  update="contextMenuId,contextMenu2Id"&gt;
              &lt;/p:commandButton&gt;
  
  &lt;h:inputHidden id="selectedEntityid"
                  value="#{myBean.selectedEntityId}"&gt;
              &lt;/h:inputHidden&gt;
  &lt;h:inputHidden id="selectedObjectType"
                  value="#{myBean.objectType}"&gt;
              &lt;/h:inputHidden&gt;
  </code></pre>