View Javadoc

1   // ---------- Attention: Generated code, please do not modify! -----------  
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   *
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
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   Renders a link element.
42    * UIComponent class, generated from template {@code component2.0.stg} with class
43    * {@link org.apache.myfaces.tobago.internal.taglib.component.LinkTagDeclaration}.
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   Deprecated! Has not longer any function.
101 
102   @deprecated*/
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   Deprecated! Use 'label' instead.
141    Text value to display as label.
142    If text contains an underscore the next character overwrites 'accesskey'.
143 
144   @deprecated*/
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   Link to an arbitrary URL, either an internal link or an external link.
159 
160    <dl>
161      <dt>internal absolute link</dt>
162      <dd>Starts with a slash '/' character. The context path will be added.
163          A session id will be added, if needed.</dd>
164      <dt>external link</dt>
165      <dd>Contains a colon ':' character.
166          The link will not be modified.</dd>
167      <dt>internal relative link</dt>
168      <dd>Any other strings. A session id will be added, if needed.</dd>
169    </dl>
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   Controls the navigation of the focus through the
182    input controls on a page with the Tab-Key.
183    The navigation starts from the element with
184    the lowest tabIndex value to the element with the highest value.
185    Elements that have identical tabIndex values should be navigated
186    in the order they appear in the character stream
187    Elements that are disabled or with a negative tabIndex
188    do not participate in the tabbing order.
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   Text value to display as tooltip.
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   This value will usually be set by the layout manager.
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   Flag indicating this component should rendered as an inline element.
257   <br />Default: <code>false</code>
258   @deprecated*/
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   This value will usually be set by the layout manager.
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   This value will usually be set by the layout manager.
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   This value will usually be set by the layout manager. It holds the current width computed by the layout manager.
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   This value will usually be set by the layout manager.
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   Flag indicating that the resource referenced by the resource attribute is a jsf resource.
413    That means that the url has to be processed to change the prefix or suffix (e. g. *.jsf or
414    /faces/*). Default is false.
415   <br />Default: <code>false</code>
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   Link to an internal resource.
431    Resources will be processed by the resource management.
432    E. g. define help.html and it will be served help_es.html or help_de.html if available.
433    For JSF-Pages you have to set the jsfResource attribute.
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   This value will usually be set by the layout manager. It holds the current height computed by the layout manager.
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   Specify, if the command calls an JSF-Action.
462    Useful to switch off the Double-Submit-Check and Waiting-Behavior.
463   <br />Default: <code>true</code>
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   Url to an image to display.
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   This attribute is for internal use only.
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   Text value to display as label.
503    If text contains an underscore the next character is used as accesskey.
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   This attribute is for internal use only.
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   Indicate the partially rendered Components in a case of a submit.
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   Name of a frame where the resource retrieved via this hyperlink is to be
599    displayed.
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   Script to be invoked when clicked
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   This attribute is for internal use only.
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   Flag indicating that this element is disabled.
651   <br />Default: <code>false</code>
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 }