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.

h:commandButtonに複数のactionListenerを指定する方法

Last updated at Posted at 2020-01-19

#目的
h:commandButton、h:commandLinkにて複数のactionListenerを指定したい際の実装方法です。
#実装方法

TestListener.java
public void method1() {
	System.out.println("method1");
}
public void method2() {
	System.out.println("method2");
}
public void method3() {
	System.out.println("method3");
}
public void method4() {
	System.out.println("method4");
}
Test.xhtml
<h:commandButton value="test"
		actionListener="#{testListener.method1()}"
		action="#{testListener.method4()}">
	<f:actionListener binding="#{testListener.method2()}"/>
	<f:actionListener binding="#{testListener.method3()}"/>
</h:commandButton>

ボタンを押した結果はこんな感じになります。

14:06:04,219 INFO  [stdout] (default task-1) method1

14:06:04,219 INFO  [stdout] (default task-1) method2

14:06:04,219 INFO  [stdout] (default task-1) method3

14:06:04,220 INFO  [stdout] (default task-1) method4
0
0
1

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?