I want to render using Richfaces a context menu on left click on a link-appearing text (blue text, and underline and cursor onmouseover). So, imagine a link which when clicked shows a context menu. Note that I don't care if the text is indeed a link, I just want it to appear as a link. So, even normal text would be fine, I would make it appear as a link using CSS.
I have the following conditions:
rich:componentControl
(these "links") are inside a datatable, so the same rich:contextMenu
must be re-used.I still have not found a satisfactory solution, as each approach I have tried has caused a problem for me:
h:outputText
(that would be ideal), I cannot attach on it a rich:componentControl
(I guess because it cannot fire an onclick event).a4j:commandLink
, although I can attach a rich:componentControl
, it makes a server request. I tried to add onclick="return false;"
to prevent the request, but Richfaces adds the JS generated by the rich:componentControl
after whatever is inside the onclick, which causes this code not to be reached at all, and of course the context menu not to appear at all.Is there any way to do this? Please remember, no request!
You may try
<rich:componentControl disableDefault="true" ...>
According to documentation with this param componentControl should add return false;
itself.
But be aware of corresponding bug: RF-5607
In case documentation lies you may use html anchors. This answer shows how to create a link with componentControl and without page refresh:
<h:outputLink value="#" id="link" onclick="return false;">
<h:outputText value="Link text"/>
<rich:componentControl attachTo="link" for="panel" operation="show" event="onclick"/>
</h:outputLink>
The onclick="return false;"
prevents the anchor from scrolling the page to the clicked link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With