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.component;
21
22 import javax.faces.context.FacesContext;
23 import org.apache.myfaces.tobago.context.Markup;
24 import org.apache.myfaces.tobago.internal.component.AbstractUILink;
25 import org.apache.myfaces.tobago.layout.Display;
26 import org.apache.myfaces.tobago.layout.Measure;
27 import org.apache.commons.lang.ArrayUtils;
28 import org.apache.commons.lang.StringUtils;
29 import org.apache.myfaces.tobago.internal.util.Deprecation;
30 import org.apache.myfaces.tobago.renderkit.MarginValues;
31 import org.apache.myfaces.tobago.renderkit.SpacingValues;
32 import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
33 import javax.el.ELException;
34 import javax.faces.FacesException;
35 import java.util.ArrayList;
36 import java.util.List;
37 import javax.el.MethodExpression;
38 import javax.el.ValueExpression;
39
40
41
42
43
44
45 public class UILink
46 extends AbstractUILink implements SupportsMarkup {
47
48 public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Link";
49
50 public static final String COMPONENT_FAMILY = "javax.faces.Command";
51
52 private org.apache.myfaces.tobago.context.Markup currentMarkup;
53
54 enum PropertyKeys {
55 accessKey,
56 markup,
57 marginLeft,
58 labelWithAccessKey,
59 link,
60 tabIndex,
61 minimumHeight,
62 tip,
63 height,
64 minimumWidth,
65 inline,
66 rowSpan,
67 left,
68 columnSpan,
69 top,
70 maximumHeight,
71 currentWidth,
72 marginTop,
73 width,
74 marginRight,
75 preferredHeight,
76 jsfResource,
77 resource,
78 currentHeight,
79 transition,
80 image,
81 display,
82 label,
83 maximumWidth,
84 preferredWidth,
85 marginBottom,
86 verticalIndex,
87 renderedPartially,
88 target,
89 onclick,
90 horizontalIndex,
91 disabled,
92 }
93
94 public String getFamily() {
95 return COMPONENT_FAMILY;
96 }
97
98
99
100
101
102
103 @Deprecated
104 public java.lang.Character getAccessKey() {
105 Deprecation.LOG.error("The attribute 'accessKey' of 'UILink' is deprecated. "
106 + "Please refer the documentation for further information.");
107 return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
108 }
109
110 @Deprecated
111 public void setAccessKey(java.lang.Character accessKey) {
112 getStateHelper().put(PropertyKeys.accessKey, accessKey);
113 }
114
115 public org.apache.myfaces.tobago.context.Markup getMarkup() {
116 Object object = getStateHelper().eval(PropertyKeys.markup);
117 if (object != null) {
118 return Markup.valueOf(object);
119 }
120 return null;
121 }
122
123 public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
124 getStateHelper().put(PropertyKeys.markup, markup);
125 }
126
127 public org.apache.myfaces.tobago.layout.Measure getMarginLeft() {
128 Object object = getStateHelper().eval(PropertyKeys.marginLeft);
129 if (object != null) {
130 return Measure.valueOf(object);
131 }
132 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this);
133 }
134
135 public void setMarginLeft(org.apache.myfaces.tobago.layout.Measure marginLeft) {
136 getStateHelper().put(PropertyKeys.marginLeft, marginLeft);
137 }
138
139
140
141
142
143
144
145 @Deprecated
146 public java.lang.String getLabelWithAccessKey() {
147 Deprecation.LOG.error("The attribute 'labelWithAccessKey' of 'UILink' is deprecated. "
148 + "Please refer the documentation for further information.");
149 return (java.lang.String) getStateHelper().eval(PropertyKeys.labelWithAccessKey);
150 }
151
152 @Deprecated
153 public void setLabelWithAccessKey(java.lang.String labelWithAccessKey) {
154 getStateHelper().put(PropertyKeys.labelWithAccessKey, labelWithAccessKey);
155 }
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172 public java.lang.String getLink() {
173 return (java.lang.String) getStateHelper().eval(PropertyKeys.link);
174 }
175
176 public void setLink(java.lang.String link) {
177 getStateHelper().put(PropertyKeys.link, link);
178 }
179
180
181
182
183
184
185
186
187
188
189
190
191 public java.lang.Integer getTabIndex() {
192 Number value = (Number) getStateHelper().eval(PropertyKeys.tabIndex);
193 if (value != null) {
194 return value.intValue();
195 }
196 return null;
197 }
198
199 public void setTabIndex(java.lang.Integer tabIndex) {
200 getStateHelper().put(PropertyKeys.tabIndex, tabIndex);
201 }
202
203 public org.apache.myfaces.tobago.layout.Measure getMinimumHeight() {
204 Object object = getStateHelper().eval(PropertyKeys.minimumHeight);
205 if (object != null) {
206 return Measure.valueOf(object);
207 }
208 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumHeight(getFacesContext(), this);
209 }
210
211 public void setMinimumHeight(org.apache.myfaces.tobago.layout.Measure minimumHeight) {
212 getStateHelper().put(PropertyKeys.minimumHeight, minimumHeight);
213 }
214
215
216
217
218
219 public java.lang.String getTip() {
220 return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
221 }
222
223 public void setTip(java.lang.String tip) {
224 getStateHelper().put(PropertyKeys.tip, tip);
225 }
226
227
228
229
230
231 public org.apache.myfaces.tobago.layout.Measure getHeight() {
232 Object object = getStateHelper().eval(PropertyKeys.height);
233 if (object != null) {
234 return Measure.valueOf(object);
235 }
236 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getHeight(getFacesContext(), this);
237 }
238
239 public void setHeight(org.apache.myfaces.tobago.layout.Measure height) {
240 getStateHelper().put(PropertyKeys.height, height);
241 }
242
243 public org.apache.myfaces.tobago.layout.Measure getMinimumWidth() {
244 Object object = getStateHelper().eval(PropertyKeys.minimumWidth);
245 if (object != null) {
246 return Measure.valueOf(object);
247 }
248 return ((LayoutComponentRenderer)getRenderer(getFacesContext())).getMinimumWidth(getFacesContext(), this);
249 }
250
251 public void setMinimumWidth(org.apache.myfaces.tobago.layout.Measure minimumWidth) {
252 getStateHelper().put(PropertyKeys.minimumWidth, minimumWidth);
253 }
254
255
256
257
258
259 @Deprecated
260 public boolean isInline() {
261 Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.inline);
262 if (bool != null) {
263 return bool;
264 }
265 return false;
266 }
267
268 @Deprecated
269 public void setInline(boolean inline) {
270 Deprecation.LOG.error("The attribute 'inline' of 'UILink' is deprecated. "
271 + "Please refer the documentation for further information.");
272 getStateHelper().put(PropertyKeys.inline, inline);
273 }
274
275 public java.lang.Integer getRowSpan() {
276 Number value = (Number) getStateHelper().eval(PropertyKeys.rowSpan);
277 if (value != null) {
278 return value.intValue();
279 }
280 return 1;
281 }
282
283 public void setRowSpan(java.lang.Integer rowSpan) {
284 getStateHelper().put(PropertyKeys.rowSpan, rowSpan);
285 }
286
287
288
289
290
291 public org.apache.myfaces.tobago.layout.Measure getLeft() {
292 Object object = getStateHelper().eval(PropertyKeys.left);
293 if (object != null) {
294 return Measure.valueOf(object);
295 }
296 return null;
297 }
298
299 public void setLeft(org.apache.myfaces.tobago.layout.Measure left) {
300 getStateHelper().put(PropertyKeys.left, left);
301 }
302
303 public java.lang.Integer getColumnSpan() {
304 Number value = (Number) getStateHelper().eval(PropertyKeys.columnSpan);
305 if (value != null) {
306 return value.intValue();
307 }
308 return 1;
309 }
310
311 public void setColumnSpan(java.lang.Integer columnSpan) {
312 getStateHelper().put(PropertyKeys.columnSpan, columnSpan);
313 }
314
315
316
317
318
319 public org.apache.myfaces.tobago.layout.Measure getTop() {
320 Object object = getStateHelper().eval(PropertyKeys.top);
321 if (object != null) {
322 return Measure.valueOf(object);
323 }
324 return null;
325 }
326
327 public void setTop(org.apache.myfaces.tobago.layout.Measure top) {
328 getStateHelper().put(PropertyKeys.top, top);
329 }
330
331 public org.apache.myfaces.tobago.layout.Measure getMaximumHeight() {
332 Object object = getStateHelper().eval(PropertyKeys.maximumHeight);
333 if (object != null) {
334 return Measure.valueOf(object);
335 }
336 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumHeight(getFacesContext(), this);
337 }
338
339 public void setMaximumHeight(org.apache.myfaces.tobago.layout.Measure maximumHeight) {
340 getStateHelper().put(PropertyKeys.maximumHeight, maximumHeight);
341 }
342
343
344
345
346
347 public org.apache.myfaces.tobago.layout.Measure getCurrentWidth() {
348 Object object = getStateHelper().eval(PropertyKeys.currentWidth);
349 if (object != null) {
350 return Measure.valueOf(object);
351 }
352 return getWidth();
353 }
354
355 public void setCurrentWidth(org.apache.myfaces.tobago.layout.Measure currentWidth) {
356 getStateHelper().put(PropertyKeys.currentWidth, currentWidth);
357 }
358
359 public org.apache.myfaces.tobago.layout.Measure getMarginTop() {
360 Object object = getStateHelper().eval(PropertyKeys.marginTop);
361 if (object != null) {
362 return Measure.valueOf(object);
363 }
364 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this);
365 }
366
367 public void setMarginTop(org.apache.myfaces.tobago.layout.Measure marginTop) {
368 getStateHelper().put(PropertyKeys.marginTop, marginTop);
369 }
370
371
372
373
374
375 public org.apache.myfaces.tobago.layout.Measure getWidth() {
376 Object object = getStateHelper().eval(PropertyKeys.width);
377 if (object != null) {
378 return Measure.valueOf(object);
379 }
380 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getWidth(getFacesContext(), this);
381 }
382
383 public void setWidth(org.apache.myfaces.tobago.layout.Measure width) {
384 getStateHelper().put(PropertyKeys.width, width);
385 }
386
387 public org.apache.myfaces.tobago.layout.Measure getMarginRight() {
388 Object object = getStateHelper().eval(PropertyKeys.marginRight);
389 if (object != null) {
390 return Measure.valueOf(object);
391 }
392 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this);
393 }
394
395 public void setMarginRight(org.apache.myfaces.tobago.layout.Measure marginRight) {
396 getStateHelper().put(PropertyKeys.marginRight, marginRight);
397 }
398
399 public org.apache.myfaces.tobago.layout.Measure getPreferredHeight() {
400 Object object = getStateHelper().eval(PropertyKeys.preferredHeight);
401 if (object != null) {
402 return Measure.valueOf(object);
403 }
404 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredHeight(getFacesContext(), this);
405 }
406
407 public void setPreferredHeight(org.apache.myfaces.tobago.layout.Measure preferredHeight) {
408 getStateHelper().put(PropertyKeys.preferredHeight, preferredHeight);
409 }
410
411
412
413
414
415
416
417 public boolean isJsfResource() {
418 Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.jsfResource);
419 if (bool != null) {
420 return bool;
421 }
422 return false;
423 }
424
425 public void setJsfResource(boolean jsfResource) {
426 getStateHelper().put(PropertyKeys.jsfResource, jsfResource);
427 }
428
429
430
431
432
433
434
435
436 public java.lang.String getResource() {
437 return (java.lang.String) getStateHelper().eval(PropertyKeys.resource);
438 }
439
440 public void setResource(java.lang.String resource) {
441 getStateHelper().put(PropertyKeys.resource, resource);
442 }
443
444
445
446
447
448 public org.apache.myfaces.tobago.layout.Measure getCurrentHeight() {
449 Object object = getStateHelper().eval(PropertyKeys.currentHeight);
450 if (object != null) {
451 return Measure.valueOf(object);
452 }
453 return getHeight();
454 }
455
456 public void setCurrentHeight(org.apache.myfaces.tobago.layout.Measure currentHeight) {
457 getStateHelper().put(PropertyKeys.currentHeight, currentHeight);
458 }
459
460
461
462
463
464
465 public boolean isTransition() {
466 Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.transition);
467 if (bool != null) {
468 return bool;
469 }
470 return true;
471 }
472
473 public void setTransition(boolean transition) {
474 getStateHelper().put(PropertyKeys.transition, transition);
475 }
476
477
478
479
480
481 public java.lang.String getImage() {
482 return (java.lang.String) getStateHelper().eval(PropertyKeys.image);
483 }
484
485 public void setImage(java.lang.String image) {
486 getStateHelper().put(PropertyKeys.image, image);
487 }
488
489
490
491
492
493 public org.apache.myfaces.tobago.layout.Display getDisplay() {
494 return (org.apache.myfaces.tobago.layout.Display) getStateHelper().eval(PropertyKeys.display);
495 }
496
497 public void setDisplay(org.apache.myfaces.tobago.layout.Display display) {
498 getStateHelper().put(PropertyKeys.display, display);
499 }
500
501
502
503
504
505
506 public java.lang.String getLabel() {
507 return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
508 }
509
510 public void setLabel(java.lang.String label) {
511 getStateHelper().put(PropertyKeys.label, label);
512 }
513
514 public org.apache.myfaces.tobago.layout.Measure getMaximumWidth() {
515 Object object = getStateHelper().eval(PropertyKeys.maximumWidth);
516 if (object != null) {
517 return Measure.valueOf(object);
518 }
519 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this);
520 }
521
522 public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
523 getStateHelper().put(PropertyKeys.maximumWidth, maximumWidth);
524 }
525
526 public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
527 Object object = getStateHelper().eval(PropertyKeys.preferredWidth);
528 if (object != null) {
529 return Measure.valueOf(object);
530 }
531 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this);
532 }
533
534 public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
535 getStateHelper().put(PropertyKeys.preferredWidth, preferredWidth);
536 }
537
538 public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
539 Object object = getStateHelper().eval(PropertyKeys.marginBottom);
540 if (object != null) {
541 return Measure.valueOf(object);
542 }
543 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this);
544 }
545
546 public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
547 getStateHelper().put(PropertyKeys.marginBottom, marginBottom);
548 }
549
550
551
552
553
554 public java.lang.Integer getVerticalIndex() {
555 Number value = (Number) getStateHelper().eval(PropertyKeys.verticalIndex);
556 if (value != null) {
557 return value.intValue();
558 }
559 return null;
560 }
561
562 public void setVerticalIndex(java.lang.Integer verticalIndex) {
563 getStateHelper().put(PropertyKeys.verticalIndex, verticalIndex);
564 }
565
566
567
568
569
570 public String[] getRenderedPartially() {
571 Object strArray = getStateHelper().eval(PropertyKeys.renderedPartially);
572 if (strArray != null) {
573 if (strArray instanceof String[]) {
574 return (String[]) strArray;
575 } else if (strArray instanceof String) {
576 String[] strings = StringUtils.split((String) strArray, ", ");
577 List<String> result = new ArrayList<String>(strings.length);
578 for (String string : strings) {
579 if (string.trim().length() != 0) {
580 result.add(string.trim());
581 }
582 }
583 return result.toArray(new String[result.size()]);
584 } else if (strArray == null) {
585 return ArrayUtils.EMPTY_STRING_ARRAY;
586 } else {
587 return new String[]{strArray.toString()};
588 }
589 }
590 return ArrayUtils.EMPTY_STRING_ARRAY;
591 }
592
593 public void setRenderedPartially(String[] renderedPartially) {
594 getStateHelper().put(PropertyKeys.renderedPartially, renderedPartially);
595 }
596
597
598
599
600
601
602 public java.lang.String getTarget() {
603 return (java.lang.String) getStateHelper().eval(PropertyKeys.target);
604 }
605
606 public void setTarget(java.lang.String target) {
607 getStateHelper().put(PropertyKeys.target, target);
608 }
609
610 public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
611 if (currentMarkup != null) {
612 return currentMarkup;
613 }
614 return null;
615 }
616
617 public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
618 this.currentMarkup = currentMarkup;
619 }
620
621
622
623
624
625 public java.lang.String getOnclick() {
626 return (java.lang.String) getStateHelper().eval(PropertyKeys.onclick);
627 }
628
629 public void setOnclick(java.lang.String onclick) {
630 getStateHelper().put(PropertyKeys.onclick, onclick);
631 }
632
633
634
635
636
637 public java.lang.Integer getHorizontalIndex() {
638 Number value = (Number) getStateHelper().eval(PropertyKeys.horizontalIndex);
639 if (value != null) {
640 return value.intValue();
641 }
642 return null;
643 }
644
645 public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
646 getStateHelper().put(PropertyKeys.horizontalIndex, horizontalIndex);
647 }
648
649
650
651
652
653 public boolean isDisabled() {
654 Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
655 if (bool != null) {
656 return bool;
657 }
658 return false;
659 }
660
661 public void setDisabled(boolean disabled) {
662 getStateHelper().put(PropertyKeys.disabled, disabled);
663 }
664
665 public Object saveState(FacesContext context) {
666 currentMarkup = null;
667 return super.saveState(context);
668 }
669
670
671 }