Note that there are some explanatory texts on larger screens.

plurals
  1. POinvoke primefaces context menu from java script
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload