0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【JSF】<h:commandLink>タグで、Ajaxイベントのみ起こして遷移させない

Last updated at Posted at 2020-01-15

やりたいこと

h:commandLinkタグに対してマウスオーバー時のAjaxイベントを定義したい!
(ツールチップのパーツとして使いたい。)

パーツをクリックしても遷移やリロードが起こらないようにしたい!

実装

以下のように実装することで実現できました

<h:commandLink onclick="return false;">ツールチップ
    <f:ajax event="mouseover" listener="#{hogeBean.hoge}" render="fuga"/>
</h:commandLink>

最初は
<a href="javascript:void(0)">遷移させない</a>
を真似て、h:commandLinkのhrefに当たる属性、outcomeを使って
<h:commandLink outcome="javascript:void(0)">遷移させない</h:commandLink>
のように書いたのですが、うまく動きませんでした。

mouseoverではなく、clickEventを扱いたい場合

hrefを指定しなければOK
レンダリング時に「href=#」と生成される。

<h:commandLink>クリック
    <f:ajax event="click" listener="#{hogeBean.hoge}" render="fuga"/>
</h:commandLink>

同じような問題にあたった方の助けになれば幸いです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?