How to use a data attribute from a target div as view param in a PrimeFaces ContextMenu outcome <p>I'm trying to do the following:</p> <ul> <li>From a simple collection of elements...</li> <li>Add a PrimeFaces ContextMenu...</li> <li>Have the first menu option forward to a new page...</li> <li>Pass a data attribute from the selected element as a view param.</li> </ul> <p>It all seems pretty straightforward, until I come to the last step, and I can't seem to find a way to get this to work.</p> <p>e.g.</p> <pre><code> &lt;div class="group" data-group="GRP1"&gt; ... &lt;/div&gt; &lt;div class="group" data-group="GRP2"&gt; ... &lt;/div&gt; &lt;div class="group" data-group="GRP3"&gt; ... &lt;/div&gt; &lt;p:contextMenu targetFilter="div.group"&gt; &lt;p:menuitem value="Edit" outcome="group.xhtml?group=GRP???"/&gt; &lt;/p:contextMenu&gt; </code></pre> <p>The divs are generated HTML and I don't really have much control over those, so probably need to do something with Javascript on the client side.</p> <p>I've tried to get hold of the group from the Javascript side, but I can't see how to bind a function to the beforeShow handler. I can see that if I can register the correct event handler then the PF code will pass me the event (from which I can get the target element and the data attribute):</p> <pre><code> // from PF menu.js if(this.cfg.beforeShow) { var retVal = this.cfg.beforeShow.call(this, e); if(retVal === false) { return; } } </code></pre> <p>But I'm not sure how to access this - if I just use inline event registration then I can only pass Javascript code not a reference to my function:</p> <pre><code> function doBeforeShow(menu, event) { var group = event.target.dataset['group']; } &lt;p:contextMenu targetFilter="div.group" beforeShow="/* this is just executed JS not a bound function */"&gt; </code></pre> <p>Anyway, even if I could get the group from the JS side, I'm not really sure what I'd do with it... probably store it somewhere and attach another handler to the p:menuitem so when it was selected it could modify the outcome before calling it?</p> <p>So I'm stuck! Anyone have any ideas on how I can get this to work?</p> <p>Thanks,</p>