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 5 years have passed since last update.

【JSF】バリデーションに引っかかった入力フィールドの背景色を変える【omnifaces】

0
Posted at

やりたいこと

  • beanValidationにひっかかった入力フィールドの背景色を赤く表示したい。
    • beanValidationはblurイベントで発火させる。
  • submit時に、エラーの出ている入力フィールドにフォーカスをあわせたい。

実現方法

omnifacesのhighlightタグを使用することで実現した
highlight - OmniFaces Showcase]
導入して<o:highlight>タグを配置するだけなのでかんたん。

omnifacesとは?

OmniFacesは、JSF 2のユーティリティライブラリであり、標準JSF APIを使用して日常のタスクを容易にするユーティリティに焦点を当てています。

注意

veanValidationの発火タイミングがblurなので、blur時にフォーカス制御が入ってしまう…
→ エラーが出たフォームからカーソルが移動できない

以下のように指定すると、blur時のフォーカス制御を無視できる。
<o:highlight focus="#{param['javax.faces.behavior.event'] ne 'blur'}" />

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?