1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.shared.renderkit.html;
20
21 import java.io.IOException;
22
23 import javax.faces.component.UIComponent;
24 import javax.faces.component.UIViewRoot;
25 import javax.faces.context.ResponseWriter;
26
27 public final class CommonPropertyUtils
28 {
29 public static long getCommonPropertiesMarked(UIComponent component)
30 {
31 Long commonProperties = (Long) component.getAttributes().get(CommonPropertyConstants.COMMON_PROPERTIES_MARKED);
32
33 if (commonProperties == null)
34 {
35 commonProperties = 0L;
36 }
37
38 return commonProperties;
39 }
40
41 public static boolean isIdRenderingNecessary(UIComponent component)
42 {
43 return component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX);
44 }
45
46 public static final void renderUniversalProperties(ResponseWriter writer,
47 long commonPropertiesMarked, UIComponent component)
48 throws IOException
49 {
50 if ((commonPropertiesMarked & CommonPropertyConstants.DIR_PROP) != 0)
51 {
52 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
53 HTML.DIR_ATTR, HTML.DIR_ATTR);
54 }
55 if ((commonPropertiesMarked & CommonPropertyConstants.LANG_PROP) != 0)
56 {
57 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
58 HTML.LANG_ATTR, HTML.LANG_ATTR);
59 }
60 if ((commonPropertiesMarked & CommonPropertyConstants.TITLE_PROP) != 0)
61 {
62 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
63 HTML.TITLE_ATTR, HTML.TITLE_ATTR);
64 }
65 }
66
67 public static final void renderUniversalPropertiesWithoutTitle(ResponseWriter writer,
68 long commonPropertiesMarked, UIComponent component)
69 throws IOException
70 {
71 if ((commonPropertiesMarked & CommonPropertyConstants.DIR_PROP) != 0)
72 {
73 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
74 HTML.DIR_ATTR, HTML.DIR_ATTR);
75 }
76 if ((commonPropertiesMarked & CommonPropertyConstants.LANG_PROP) != 0)
77 {
78 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
79 HTML.LANG_ATTR, HTML.LANG_ATTR);
80 }
81 }
82
83 public static final void renderStyleProperties(ResponseWriter writer,
84 long commonPropertiesMarked, UIComponent component)
85 throws IOException
86 {
87 if ((commonPropertiesMarked & CommonPropertyConstants.STYLE_PROP) != 0)
88 {
89 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
90 HTML.STYLE_ATTR, HTML.STYLE_ATTR);
91 }
92 if ((commonPropertiesMarked & CommonPropertyConstants.STYLECLASS_PROP) != 0)
93 {
94 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
95 HTML.STYLE_CLASS_ATTR, HTML.CLASS_ATTR);
96 }
97 }
98
99 public static final void renderEventProperties(ResponseWriter writer,
100 long commonPropertiesMarked, UIComponent component)
101 throws IOException
102 {
103 if ((commonPropertiesMarked & CommonPropertyConstants.ONCLICK_PROP) != 0)
104 {
105 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
106 HTML.ONCLICK_ATTR, HTML.ONCLICK_ATTR);
107 }
108 renderEventPropertiesWithoutOnclick(writer, commonPropertiesMarked, component);
109 }
110
111 public static final void renderEventPropertiesWithoutOnclick(ResponseWriter writer,
112 long commonPropertiesMarked, UIComponent component)
113 throws IOException
114 {
115 if ((commonPropertiesMarked & CommonPropertyConstants.ONDBLCLICK_PROP) != 0)
116 {
117 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
118 HTML.ONDBLCLICK_ATTR, HTML.ONDBLCLICK_ATTR);
119 }
120 if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEDOWN_PROP) != 0)
121 {
122 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
123 HTML.ONMOUSEDOWN_ATTR, HTML.ONMOUSEDOWN_ATTR);
124 }
125 if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEUP_PROP) != 0)
126 {
127 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
128 HTML.ONMOUSEUP_ATTR, HTML.ONMOUSEUP_ATTR);
129 }
130 if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEOVER_PROP) != 0)
131 {
132 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
133 HTML.ONMOUSEOVER_ATTR, HTML.ONMOUSEOVER_ATTR);
134 }
135 if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEMOVE_PROP) != 0)
136 {
137 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
138 HTML.ONMOUSEMOVE_ATTR, HTML.ONMOUSEMOVE_ATTR);
139 }
140 if ((commonPropertiesMarked & CommonPropertyConstants.ONMOUSEOUT_PROP) != 0)
141 {
142 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
143 HTML.ONMOUSEOUT_ATTR, HTML.ONMOUSEOUT_ATTR);
144 }
145 if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYPRESS_PROP) != 0)
146 {
147 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
148 HTML.ONKEYPRESS_ATTR, HTML.ONKEYPRESS_ATTR);
149 }
150 if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYDOWN_PROP) != 0)
151 {
152 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
153 HTML.ONKEYDOWN_ATTR, HTML.ONKEYDOWN_ATTR);
154 }
155 if ((commonPropertiesMarked & CommonPropertyConstants.ONKEYUP_PROP) != 0)
156 {
157 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
158 HTML.ONKEYUP_ATTR, HTML.ONKEYUP_ATTR);
159 }
160 }
161
162
163 public static final void renderChangeSelectEventProperties(ResponseWriter writer,
164 long commonPropertiesMarked, UIComponent component)
165 throws IOException
166 {
167 if ((commonPropertiesMarked & CommonPropertyConstants.ONCHANGE_PROP) != 0)
168 {
169 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
170 HTML.ONCHANGE_ATTR, HTML.ONCHANGE_ATTR);
171 }
172 if ((commonPropertiesMarked & CommonPropertyConstants.ONSELECT_PROP) != 0)
173 {
174 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
175 HTML.ONSELECT_ATTR, HTML.ONSELECT_ATTR);
176 }
177 }
178
179 public static final void renderFocusBlurEventProperties(ResponseWriter writer,
180 long commonPropertiesMarked, UIComponent component)
181 throws IOException
182 {
183 if ((commonPropertiesMarked & CommonPropertyConstants.ONFOCUS_PROP) != 0)
184 {
185 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
186 HTML.ONFOCUS_ATTR, HTML.ONFOCUS_ATTR);
187 }
188 if ((commonPropertiesMarked & CommonPropertyConstants.ONBLUR_PROP) != 0)
189 {
190 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
191 HTML.ONBLUR_ATTR, HTML.ONBLUR_ATTR);
192 }
193 }
194
195 public static final void renderFieldEventPropertiesWithoutOnchangeAndOnselect(ResponseWriter writer,
196 long commonPropertiesMarked, UIComponent component) throws IOException
197 {
198 if ((commonPropertiesMarked & CommonPropertyConstants.ONFOCUS_PROP) != 0)
199 {
200 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
201 HTML.ONFOCUS_ATTR, HTML.ONFOCUS_ATTR);
202 }
203 if ((commonPropertiesMarked & CommonPropertyConstants.ONBLUR_PROP) != 0)
204 {
205 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
206 HTML.ONBLUR_ATTR, HTML.ONBLUR_ATTR);
207 }
208 }
209
210 public static final void renderFieldEventPropertiesWithoutOnchange(ResponseWriter writer,
211 long commonPropertiesMarked, UIComponent component) throws IOException
212 {
213 if ((commonPropertiesMarked & CommonPropertyConstants.ONFOCUS_PROP) != 0)
214 {
215 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
216 HTML.ONFOCUS_ATTR, HTML.ONFOCUS_ATTR);
217 }
218 if ((commonPropertiesMarked & CommonPropertyConstants.ONBLUR_PROP) != 0)
219 {
220 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
221 HTML.ONBLUR_ATTR, HTML.ONBLUR_ATTR);
222 }
223 if ((commonPropertiesMarked & CommonPropertyConstants.ONSELECT_PROP) != 0)
224 {
225 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
226 HTML.ONSELECT_ATTR, HTML.ONSELECT_ATTR);
227 }
228 }
229
230 public static final void renderChangeEventProperty(ResponseWriter writer,
231 long commonPropertiesMarked, UIComponent component) throws IOException
232 {
233 if ((commonPropertiesMarked & CommonPropertyConstants.ONCHANGE_PROP) != 0)
234 {
235 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
236 HTML.ONCHANGE_ATTR, HTML.ONCHANGE_ATTR);
237 }
238 }
239
240 public static void renderAccesskeyTabindexProperties(ResponseWriter writer,
241 long commonPropertiesMarked, UIComponent component)
242 throws IOException
243 {
244 if ((commonPropertiesMarked & CommonPropertyConstants.ACCESSKEY_PROP) != 0)
245 {
246 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
247 HTML.ACCESSKEY_ATTR, HTML.ACCESSKEY_ATTR);
248 }
249 if ((commonPropertiesMarked & CommonPropertyConstants.TABINDEX_PROP) != 0)
250 {
251 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
252 HTML.TABINDEX_ATTR, HTML.TABINDEX_ATTR);
253 }
254 }
255
256 public static void renderAltAlignProperties(ResponseWriter writer,
257 long commonPropertiesMarked, UIComponent component)
258 throws IOException
259 {
260 if ((commonPropertiesMarked & CommonPropertyConstants.ALIGN_PROP) != 0)
261 {
262 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
263 HTML.ALIGN_ATTR, HTML.ALIGN_ATTR);
264 }
265 if ((commonPropertiesMarked & CommonPropertyConstants.ALT_PROP) != 0)
266 {
267 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
268 HTML.ALT_ATTR, HTML.ALT_ATTR);
269 }
270 }
271
272 public static final void renderInputProperties(ResponseWriter writer,
273 long commonPropertiesMarked, UIComponent component)
274 throws IOException
275 {
276 if ((commonPropertiesMarked & CommonPropertyConstants.ALIGN_PROP) != 0)
277 {
278 HtmlRendererUtils.renderHTMLAttribute(writer, component,
279 HTML.ALIGN_ATTR, HTML.ALIGN_ATTR);
280 }
281 if ((commonPropertiesMarked & CommonPropertyConstants.ALT_PROP) != 0)
282 {
283 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
284 HTML.ALT_ATTR, HTML.ALT_ATTR);
285 }
286 if ((commonPropertiesMarked & CommonPropertyConstants.CHECKED_PROP) != 0)
287 {
288 HtmlRendererUtils.renderHTMLAttribute(writer, component,
289 HTML.CHECKED_ATTR, HTML.CHECKED_ATTR);
290 }
291 if ((commonPropertiesMarked & CommonPropertyConstants.MAXLENGTH_PROP) != 0)
292 {
293 HtmlRendererUtils.renderHTMLAttribute(writer, component,
294 HTML.MAXLENGTH_ATTR, HTML.MAXLENGTH_ATTR);
295 }
296 if ((commonPropertiesMarked & CommonPropertyConstants.READONLY_PROP) != 0)
297 {
298 HtmlRendererUtils.renderHTMLAttribute(writer, component,
299 HTML.READONLY_ATTR, HTML.READONLY_ATTR);
300 }
301 if ((commonPropertiesMarked & CommonPropertyConstants.SIZE_PROP) != 0)
302 {
303 HtmlRendererUtils.renderHTMLAttribute(writer, component,
304 HTML.SIZE_ATTR, HTML.SIZE_ATTR);
305 }
306 }
307
308 public static final void renderAnchorProperties(ResponseWriter writer,
309 long commonPropertiesMarked, UIComponent component)
310 throws IOException
311 {
312 renderAccesskeyTabindexProperties(writer, commonPropertiesMarked, component);
313 if ((commonPropertiesMarked & CommonPropertyConstants.CHARSET_PROP) != 0)
314 {
315 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
316 HTML.CHARSET_ATTR, HTML.CHARSET_ATTR);
317 }
318 if ((commonPropertiesMarked & CommonPropertyConstants.COORDS_PROP) != 0)
319 {
320 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
321 HTML.COORDS_ATTR, HTML.COORDS_ATTR);
322 }
323 if ((commonPropertiesMarked & CommonPropertyConstants.HREFLANG_PROP) != 0)
324 {
325 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
326 HTML.HREFLANG_ATTR, HTML.HREFLANG_ATTR);
327 }
328 if ((commonPropertiesMarked & CommonPropertyConstants.REL_PROP) != 0)
329 {
330 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
331 HTML.REL_ATTR, HTML.REL_ATTR);
332 }
333 if ((commonPropertiesMarked & CommonPropertyConstants.REV_PROP) != 0)
334 {
335 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
336 HTML.REV_ATTR, HTML.REV_ATTR);
337 }
338 if ((commonPropertiesMarked & CommonPropertyConstants.SHAPE_PROP) != 0)
339 {
340 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
341 HTML.SHAPE_ATTR, HTML.SHAPE_ATTR);
342 }
343 if ((commonPropertiesMarked & CommonPropertyConstants.TARGET_PROP) != 0)
344 {
345 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
346 HTML.TARGET_ATTR, HTML.TARGET_ATTR);
347 }
348 if ((commonPropertiesMarked & CommonPropertyConstants.TYPE_PROP) != 0)
349 {
350 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
351 HTML.TYPE_ATTR, HTML.TYPE_ATTR);
352 }
353 }
354
355 public static final void renderCommonPassthroughPropertiesWithoutEvents(ResponseWriter writer,
356 long commonPropertiesMarked, UIComponent component)
357 throws IOException
358 {
359 renderStyleProperties(writer, commonPropertiesMarked, component);
360 renderUniversalProperties(writer, commonPropertiesMarked, component);
361 }
362
363 public static final void renderCommonPassthroughProperties(ResponseWriter writer,
364 long commonPropertiesMarked, UIComponent component)
365 throws IOException
366 {
367 renderStyleProperties(writer, commonPropertiesMarked, component);
368 renderUniversalProperties(writer, commonPropertiesMarked, component);
369 renderEventProperties(writer, commonPropertiesMarked, component);
370 }
371
372
373 public static final void renderCommonFieldEventProperties(ResponseWriter writer,
374 long commonPropertiesMarked, UIComponent component)
375 throws IOException
376 {
377 renderChangeSelectEventProperties(writer, commonPropertiesMarked, component);
378 renderFocusBlurEventProperties(writer, commonPropertiesMarked, component);
379 }
380
381 public static final void renderCommonFieldPassthroughPropertiesWithoutDisabled(ResponseWriter writer,
382 long commonPropertiesMarked, UIComponent component)
383 throws IOException
384 {
385 renderCommonPassthroughProperties(writer, commonPropertiesMarked, component);
386 renderAccesskeyTabindexProperties(writer, commonPropertiesMarked, component);
387 renderCommonFieldEventProperties(writer, commonPropertiesMarked, component);
388 }
389
390 public static final void renderCommonFieldPassthroughPropertiesWithoutDisabledAndEvents(ResponseWriter writer,
391 long commonPropertiesMarked, UIComponent component)
392 throws IOException
393 {
394 renderCommonPassthroughPropertiesWithoutEvents(writer, commonPropertiesMarked, component);
395 renderAccesskeyTabindexProperties(writer, commonPropertiesMarked, component);
396 }
397
398 public static final void renderInputPassthroughPropertiesWithoutDisabled(ResponseWriter writer,
399 long commonPropertiesMarked, UIComponent component)
400 throws IOException
401 {
402 renderInputProperties(writer, commonPropertiesMarked, component);
403 renderCommonFieldPassthroughPropertiesWithoutDisabled(writer, commonPropertiesMarked, component);
404 }
405
406 public static final void renderInputPassthroughPropertiesWithoutDisabledAndEvents(ResponseWriter writer,
407 long commonPropertiesMarked, UIComponent component)
408 throws IOException
409 {
410 renderInputProperties(writer, commonPropertiesMarked, component);
411 renderCommonFieldPassthroughPropertiesWithoutDisabledAndEvents(writer, commonPropertiesMarked, component);
412 }
413
414 public static final void renderAnchorPassthroughProperties(ResponseWriter writer,
415 long commonPropertiesMarked, UIComponent component)
416 throws IOException
417 {
418 renderAnchorProperties(writer, commonPropertiesMarked, component);
419 renderCommonPassthroughProperties(writer, commonPropertiesMarked, component);
420 renderFocusBlurEventProperties(writer, commonPropertiesMarked, component);
421 }
422
423 public static final void renderAnchorPassthroughPropertiesWithoutEvents(ResponseWriter writer,
424 long commonPropertiesMarked, UIComponent component)
425 throws IOException
426 {
427 renderAnchorProperties(writer, commonPropertiesMarked, component);
428 renderStyleProperties(writer, commonPropertiesMarked, component);
429 renderUniversalProperties(writer, commonPropertiesMarked, component);
430 }
431
432 public static final void renderAnchorPassthroughPropertiesWithoutStyleAndEvents(ResponseWriter writer,
433 long commonPropertiesMarked, UIComponent component)
434 throws IOException
435 {
436 renderAnchorProperties(writer, commonPropertiesMarked, component);
437 renderUniversalProperties(writer, commonPropertiesMarked, component);
438 }
439
440 public static final void renderAnchorPassthroughPropertiesWithoutStyle(ResponseWriter writer,
441 long commonPropertiesMarked, UIComponent component)
442 throws IOException
443 {
444 renderAnchorProperties(writer, commonPropertiesMarked, component);
445 renderUniversalProperties(writer, commonPropertiesMarked, component);
446 renderEventProperties(writer, commonPropertiesMarked, component);
447 renderFocusBlurEventProperties(writer, commonPropertiesMarked, component);
448 }
449
450 public static final void renderAnchorPassthroughPropertiesWithoutOnclickAndStyle(ResponseWriter writer,
451 long commonPropertiesMarked, UIComponent component)
452 throws IOException
453 {
454 renderAnchorProperties(writer, commonPropertiesMarked, component);
455 renderUniversalProperties(writer, commonPropertiesMarked, component);
456 renderEventPropertiesWithoutOnclick(writer, commonPropertiesMarked, component);
457 renderFocusBlurEventProperties(writer, commonPropertiesMarked, component);
458 }
459
460 public static final void renderButtonPassthroughPropertiesWithoutDisabledAndEvents(ResponseWriter writer,
461 long commonPropertiesMarked, UIComponent component)
462 throws IOException
463 {
464 renderUniversalProperties(writer, commonPropertiesMarked, component);
465 renderStyleProperties(writer, commonPropertiesMarked, component);
466 renderAccesskeyTabindexProperties(writer, commonPropertiesMarked, component);
467 renderAltAlignProperties(writer, commonPropertiesMarked, component);
468 }
469
470 public static final void renderLabelProperties(ResponseWriter writer,
471 long commonPropertiesMarked, UIComponent component)
472 throws IOException
473 {
474 renderFocusBlurEventProperties(writer, commonPropertiesMarked, component);
475 if ((commonPropertiesMarked & CommonPropertyConstants.ACCESSKEY_PROP) != 0)
476 {
477 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
478 HTML.ACCESSKEY_ATTR, HTML.ACCESSKEY_ATTR);
479 }
480 }
481
482
483 public static final void renderLabelPassthroughProperties(ResponseWriter writer,
484 long commonPropertiesMarked, UIComponent component)
485 throws IOException
486 {
487 renderLabelProperties(writer, commonPropertiesMarked, component);
488 renderCommonPassthroughProperties(writer, commonPropertiesMarked, component);
489 }
490
491 public static final void renderLabelPassthroughPropertiesWithoutEvents(ResponseWriter writer,
492 long commonPropertiesMarked, UIComponent component)
493 throws IOException
494 {
495 if ((commonPropertiesMarked & CommonPropertyConstants.ACCESSKEY_PROP) != 0)
496 {
497 HtmlRendererUtils.renderHTMLStringAttribute(writer, component,
498 HTML.ACCESSKEY_ATTR, HTML.ACCESSKEY_ATTR);
499 }
500 renderCommonPassthroughPropertiesWithoutEvents(writer, commonPropertiesMarked, component);
501 }
502
503 public static final void renderSelectPassthroughPropertiesWithoutDisabled(ResponseWriter writer,
504 long commonPropertiesMarked, UIComponent component)
505 throws IOException
506 {
507 renderCommonFieldPassthroughPropertiesWithoutDisabled(writer, commonPropertiesMarked, component);
508 }
509
510 public static final void renderSelectPassthroughPropertiesWithoutDisabledAndEvents(ResponseWriter writer,
511 long commonPropertiesMarked, UIComponent component)
512 throws IOException
513 {
514 renderCommonFieldPassthroughPropertiesWithoutDisabledAndEvents(writer, commonPropertiesMarked, component);
515 }
516 }