Richfaces: Link-like text with ContextMenu
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:
- The context menu must appear on client side, without making a request.
- The context menu must appear using a
rich:componentControl
(these "links") are inside a datatable, so the samerich: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:
- If I use
h:outputText
(that would be ideal), I cannot attach on it arich:componentControl
(I guess because it cannot fire an onclick event). - If I use
a4j:commandLink
, although I can attach arich:componentControl
, it makes a server request. I tried to addonclick="return false;"
to prevent the request, but R开发者_如何学运维ichfaces adds the JS generated by therich: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.
精彩评论