开发者

Richfaces: Link-like text with ContextMenu

开发者 https://www.devze.com 2023-02-09 04:02 出处:网络
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. No

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 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:

  1. If I use h:outputText (that would be ideal), I cannot attach on it a rich:componentControl (I guess because it cannot fire an onclick event).
  2. If I use 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 R开发者_如何学运维ichfaces 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消