1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.example.demo;
21
22 import javax.enterprise.context.SessionScoped;
23 import javax.faces.event.ActionEvent;
24 import javax.faces.event.AjaxBehaviorEvent;
25 import javax.inject.Named;
26 import java.io.Serializable;
27
28 @SessionScoped
29 @Named
30 public class BehaviorTestController implements Serializable {
31
32 private int buttonActionCounter;
33 private int buttonActionListenerCounter;
34 private int actionCounter1;
35 private int actionListenerCounter1;
36 private int ajaxListenerCounter1;
37 private int actionCounter2;
38 private int actionListenerCounter2;
39 private int ajaxListenerCounter2;
40 private int actionCounter3;
41 private int actionListenerCounter3;
42 private int ajaxListenerCounter3;
43 private int selector;
44 private boolean eventEnabled1;
45 private boolean eventEnabled2;
46 private boolean eventEnabled3;
47 private boolean ajaxEnabled1;
48 private boolean ajaxEnabled2;
49 private boolean ajaxEnabled3;
50
51 public BehaviorTestController() {
52 reset();
53 }
54
55 public void reset() {
56 buttonActionCounter = 0;
57 buttonActionListenerCounter = 0;
58 actionCounter1 = 0;
59 actionListenerCounter1 = 0;
60 ajaxListenerCounter1 = 0;
61 actionCounter2 = 0;
62 actionListenerCounter2 = 0;
63 ajaxListenerCounter2 = 0;
64 actionCounter3 = 0;
65 actionListenerCounter3 = 0;
66 ajaxListenerCounter3 = 0;
67 }
68
69 public void countButtonAction() {
70 buttonActionCounter++;
71 }
72
73 public void countButtonActionListener(ActionEvent actionEvent) {
74 buttonActionListenerCounter++;
75 }
76
77 public void countAction1() {
78 actionCounter1++;
79 }
80
81 public void countActionListener1(ActionEvent actionEvent) {
82 actionListenerCounter1++;
83 }
84
85 public void countAjaxListener1(AjaxBehaviorEvent ajaxBehaviorEvent) {
86 ajaxListenerCounter1++;
87 }
88
89 public void countAction2() {
90 actionCounter2++;
91 }
92
93 public void countActionListener2(ActionEvent actionEvent) {
94 actionListenerCounter2++;
95 }
96
97 public void countAjaxListener2(AjaxBehaviorEvent ajaxBehaviorEvent) {
98 ajaxListenerCounter2++;
99 }
100
101 public void countAction3() {
102 actionCounter3++;
103 }
104
105 public void countActionListener3(ActionEvent actionEvent) {
106 actionListenerCounter3++;
107 }
108
109 public void countAjaxListener3(AjaxBehaviorEvent ajaxBehaviorEvent) {
110 ajaxListenerCounter3++;
111 }
112
113 public int getSelector() {
114 return selector;
115 }
116
117 public void setSelector(int selector) {
118 this.selector = selector;
119 }
120
121 public void submitSelection() {
122 eventEnabled1 = false;
123 eventEnabled2 = false;
124 eventEnabled3 = false;
125 ajaxEnabled1 = false;
126 ajaxEnabled2 = false;
127 ajaxEnabled3 = false;
128
129 switch (selector) {
130 case 1:
131 eventEnabled1 = true;
132 break;
133 case 2:
134 eventEnabled2 = true;
135 ajaxEnabled3 = true;
136 break;
137 case 3:
138 eventEnabled3 = true;
139 ajaxEnabled1 = true;
140 ajaxEnabled2 = true;
141 ajaxEnabled3 = true;
142 break;
143 default:
144 }
145 }
146
147 public int getButtonActionCounter() {
148 return buttonActionCounter;
149 }
150
151 public int getButtonActionListenerCounter() {
152 return buttonActionListenerCounter;
153 }
154
155 public int getActionCounter1() {
156 return actionCounter1;
157 }
158
159 public int getActionListenerCounter1() {
160 return actionListenerCounter1;
161 }
162
163 public int getAjaxListenerCounter1() {
164 return ajaxListenerCounter1;
165 }
166
167 public int getActionCounter2() {
168 return actionCounter2;
169 }
170
171 public int getActionListenerCounter2() {
172 return actionListenerCounter2;
173 }
174
175 public int getAjaxListenerCounter2() {
176 return ajaxListenerCounter2;
177 }
178
179 public int getActionCounter3() {
180 return actionCounter3;
181 }
182
183 public int getActionListenerCounter3() {
184 return actionListenerCounter3;
185 }
186
187 public int getAjaxListenerCounter3() {
188 return ajaxListenerCounter3;
189 }
190
191 public boolean isEventEnabled1() {
192 return eventEnabled1;
193 }
194
195 public boolean isEventEnabled2() {
196 return eventEnabled2;
197 }
198
199 public boolean isEventEnabled3() {
200 return eventEnabled3;
201 }
202
203 public boolean isAjaxEnabled1() {
204 return ajaxEnabled1;
205 }
206
207 public boolean isAjaxEnabled2() {
208 return ajaxEnabled2;
209 }
210
211 public boolean isAjaxEnabled3() {
212 return ajaxEnabled3;
213 }
214 }