1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts.faces.component;
23
24 import jakarta.el.ValueExpression;
25 import jakarta.faces.component.UIOutput;
26 import jakarta.faces.context.FacesContext;
27
28
29
30
31
32
33
34
35
36
37
38
39
40 public class JavascriptValidatorComponent extends UIOutput {
41
42
43
44
45
46
47
48
49 public JavascriptValidatorComponent() {
50
51 super();
52 setRendererType("org.apache.struts.faces.JavascriptValidator");
53
54 }
55
56
57
58
59
60
61
62
63 private String bundle = null;
64
65
66
67
68
69
70 private String formName = null;
71
72
73
74
75
76 private int page = 0;
77 private boolean pageSet = false;
78
79
80
81
82
83
84 private String method = null;
85
86
87
88
89
90 private boolean staticJavascript = true;
91 private boolean staticJavascriptSet = false;
92
93
94
95
96
97 private boolean dynamicJavascript = true;
98 private boolean dynamicJavascriptSet = false;
99
100
101
102
103
104
105 private String src = null;
106
107
108
109
110
111 private boolean htmlComment = true;
112 private boolean htmlCommentSet = false;
113
114
115
116
117 private boolean cdata = true;
118 private boolean cdataSet = false;
119
120
121
122
123
124
125
126
127 public String getBundle() {
128
129 if (bundle != null) {
130 return bundle;
131 }
132 ValueExpression vb = getValueExpression("bundle");
133 if (vb != null) {
134 return (String) vb.getValue(getFacesContext().getELContext());
135 } else {
136 return null;
137 }
138
139 }
140
141
142
143
144
145
146
147 public void setBundle(String bundle) {
148
149 this.bundle = bundle;
150
151 }
152
153
154
155
156 public String getFamily() {
157
158 return "org.apache.struts.faces.JavascriptValidator";
159
160 }
161
162
163
164
165
166
167 public String getFormName() {
168
169 if (formName != null) {
170 return formName;
171 }
172 ValueExpression vb = getValueExpression("formName");
173 if (vb != null) {
174 return (String) vb.getValue(getFacesContext().getELContext());
175 } else {
176 return null;
177 }
178
179 }
180
181
182
183
184
185
186
187
188 public void setFormName(String formName) {
189
190 this.formName = formName;
191
192 }
193
194
195
196
197
198
199
200 public int getPage() {
201
202 if (pageSet) {
203 return page;
204 }
205 ValueExpression vb = getValueExpression("page");
206 if (vb != null) {
207 return (Integer) vb.getValue(getFacesContext().getELContext());
208 } else {
209 return 0;
210 }
211
212 }
213
214
215
216
217
218
219
220 public void setPage(int page) {
221
222 this.page = page;
223 this.pageSet = true;
224
225 }
226
227
228
229
230
231
232
233 public String getMethod() {
234
235 if (method != null) {
236 return method;
237 }
238 ValueExpression vb = getValueExpression("method");
239 if (vb != null) {
240 return (String) vb.getValue(getFacesContext().getELContext());
241 } else {
242 return null;
243 }
244
245 }
246
247
248
249
250
251
252
253 public void setMethod(String method) {
254
255 this.method = method;
256
257 }
258
259
260
261
262
263
264 public boolean isStaticJavascript() {
265
266 if (staticJavascriptSet) {
267 return staticJavascript;
268 }
269 ValueExpression vb = getValueExpression("staticJavascript");
270 if (vb != null) {
271 return (Boolean) vb.getValue(getFacesContext().getELContext());
272 } else {
273 return true;
274 }
275
276 }
277
278
279
280
281
282
283 public void setStaticJavascript(boolean staticJavascript) {
284
285 this.staticJavascript = staticJavascript;
286 this.staticJavascriptSet = true;
287
288 }
289
290
291
292
293
294
295 public boolean isDynamicJavascript() {
296
297 if (dynamicJavascriptSet) {
298 return dynamicJavascript;
299 }
300 ValueExpression vb = getValueExpression("dynamicJavascript");
301 if (vb != null) {
302 return (Boolean) vb.getValue(getFacesContext().getELContext());
303 } else {
304 return true;
305 }
306
307 }
308
309
310
311
312
313
314 public void setDynamicJavascript(boolean dynamicJavascript) {
315
316 this.dynamicJavascript = dynamicJavascript;
317 this.dynamicJavascriptSet = true;
318
319 }
320
321
322
323
324
325 public String getSrc() {
326
327 if (src != null) {
328 return src;
329 }
330 ValueExpression vb = getValueExpression("src");
331 if (vb != null) {
332 return (String) vb.getValue(getFacesContext().getELContext());
333 } else {
334 return null;
335 }
336
337 }
338
339
340
341
342
343
344 public void setSrc(String src) {
345
346 this.src = src;
347
348 }
349
350
351
352
353
354
355 public boolean isHtmlComment() {
356
357 if (htmlCommentSet) {
358 return htmlComment;
359 }
360 ValueExpression vb = getValueExpression("htmlComment");
361 if (vb != null) {
362 return (Boolean) vb.getValue(getFacesContext().getELContext());
363 } else {
364 return true;
365 }
366
367 }
368
369
370
371
372
373
374 public void setHtmlComment(boolean htmlComment) {
375
376 this.htmlComment = htmlComment;
377 this.htmlCommentSet = true;
378
379 }
380
381
382
383
384
385 public boolean isCdata() {
386
387 if (cdataSet) {
388 return cdata;
389 }
390 ValueExpression vb = getValueExpression("cdata");
391 if (vb != null) {
392 return (Boolean) vb.getValue(getFacesContext().getELContext());
393 } else {
394 return true;
395 }
396
397 }
398
399
400
401
402
403 public void setCdata(boolean cdata) {
404
405 this.cdata = cdata;
406 this.cdataSet = true;
407
408 }
409
410
411
412
413
414
415
416
417
418
419
420 public void restoreState(FacesContext context, Object state) {
421
422 Object values[] = (Object[]) state;
423 super.restoreState(context, values[0]);
424 bundle = (String) values[1];
425 formName = (String) values[2];
426 page = (Integer) values[3];
427 pageSet = (Boolean) values[4];
428 method = (String) values[5];
429 staticJavascript = (Boolean) values[6];
430 staticJavascriptSet = (Boolean) values[7];
431 dynamicJavascript = (Boolean) values[8];
432 dynamicJavascriptSet = (Boolean) values[9];
433 src = (String) values[10];
434 htmlComment = (Boolean) values[11];
435 htmlCommentSet = (Boolean) values[12];
436 cdata = (Boolean) values[13];
437 cdataSet = (Boolean) values[14];
438
439 }
440
441
442
443
444
445
446
447 public Object saveState(FacesContext context) {
448
449 Object values[] = new Object[15];
450 values[0] = super.saveState(context);
451 values[1] = bundle;
452 values[2] = formName;
453 values[3] = page;
454 values[4] = pageSet;
455 values[5] = method;
456 values[6] = staticJavascript;
457 values[7] = staticJavascriptSet;
458 values[8] = dynamicJavascript;
459 values[9] = dynamicJavascriptSet;
460 values[10] = src;
461 values[11] = htmlComment;
462 values[12] = htmlCommentSet;
463 values[13] = cdata;
464 values[14] = cdataSet;
465 return values;
466
467 }
468
469
470 }