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.myfaces.tobago.internal.util.ArrayUtils;
28  import org.apache.myfaces.tobago.internal.util.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      link,
59      labelWithAccessKey,
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      omit,
88      renderedPartially,
89      target,
90      onclick,
91      horizontalIndex,
92      disabled,
93    }
94  
95    public String getFamily() {
96      return COMPONENT_FAMILY;
97    }
98  
99  
100   /**
101   Deprecated! Has not longer any function.
102 
103   @deprecated*/
104   @Deprecated
105   public java.lang.Character getAccessKey() {
106     return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
107   }
108 
109   @Deprecated
110   public void setAccessKey(java.lang.Character accessKey) {
111       Deprecation.LOG.error("The attribute 'accessKey' of 'UILink' is deprecated. "
112           + "Please refer the documentation for further information.");
113     getStateHelper().put(PropertyKeys.accessKey, accessKey);
114   }
115 
116   public org.apache.myfaces.tobago.context.Markup getMarkup() {
117     Object object = getStateHelper().eval(PropertyKeys.markup);
118     if (object != null) {
119       return Markup.valueOf(object);
120     }
121     return null;
122   }
123 
124   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
125     getStateHelper().put(PropertyKeys.markup, markup);
126   }
127 
128   public org.apache.myfaces.tobago.layout.Measure getMarginLeft() {
129     Object object = getStateHelper().eval(PropertyKeys.marginLeft);
130     if (object != null) {
131        return Measure.valueOf(object);
132     }
133     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this) : Measure.ZERO;
134   }
135 
136   public void setMarginLeft(org.apache.myfaces.tobago.layout.Measure marginLeft) {
137     getStateHelper().put(PropertyKeys.marginLeft, marginLeft);
138   }
139 
140   /**
141   Link to an arbitrary URL, either an internal link or an external link.
142 
143    <dl>
144      <dt>internal absolute link</dt>
145      <dd>Starts with a slash '/' character. The context path will be added.
146          A session id will be added, if needed.</dd>
147      <dt>external link</dt>
148      <dd>Contains a colon ':' character.
149          The link will not be modified.</dd>
150      <dt>internal relative link</dt>
151      <dd>Any other strings. A session id will be added, if needed.</dd>
152    </dl>
153 
154   */
155   public java.lang.String getLink() {
156     return (java.lang.String) getStateHelper().eval(PropertyKeys.link);
157   }
158 
159   public void setLink(java.lang.String link) {
160     getStateHelper().put(PropertyKeys.link, link);
161   }
162 
163   /**
164   Deprecated! Use 'label' instead.
165    Text value to display as label.
166    If text contains an underscore the next character overwrites 'accesskey'.
167 
168   @deprecated*/
169   @Deprecated
170   public java.lang.String getLabelWithAccessKey() {
171     return (java.lang.String) getStateHelper().eval(PropertyKeys.labelWithAccessKey);
172   }
173 
174   @Deprecated
175   public void setLabelWithAccessKey(java.lang.String labelWithAccessKey) {
176       Deprecation.LOG.error("The attribute 'labelWithAccessKey' of 'UILink' is deprecated. "
177           + "Please refer the documentation for further information.");
178     getStateHelper().put(PropertyKeys.labelWithAccessKey, labelWithAccessKey);
179   }
180 
181   /**
182   Controls the navigation of the focus through the
183    input controls on a page with the Tab-Key.
184    The navigation starts from the element with
185    the lowest tabIndex value to the element with the highest value.
186    Elements that have identical tabIndex values should be navigated
187    in the order they appear in the character stream
188    Elements that are disabled or with a negative tabIndex
189    do not participate in the tabbing order.
190 
191   */
192   public java.lang.Integer getTabIndex() {
193     Number value  = (Number) getStateHelper().eval(PropertyKeys.tabIndex);
194     if (value != null) {
195       return value.intValue();
196     }
197     return null;
198   }
199 
200   public void setTabIndex(java.lang.Integer tabIndex) {
201     getStateHelper().put(PropertyKeys.tabIndex, tabIndex);
202   }
203 
204   public org.apache.myfaces.tobago.layout.Measure getMinimumHeight() {
205     Object object = getStateHelper().eval(PropertyKeys.minimumHeight);
206     if (object != null) {
207        return Measure.valueOf(object);
208     }
209     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumHeight(getFacesContext(), this) : Measure.ZERO;
210   }
211 
212   public void setMinimumHeight(org.apache.myfaces.tobago.layout.Measure minimumHeight) {
213     getStateHelper().put(PropertyKeys.minimumHeight, minimumHeight);
214   }
215 
216   /**
217   Text value to display as tooltip.
218 
219   */
220   public java.lang.String getTip() {
221     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
222   }
223 
224   public void setTip(java.lang.String tip) {
225     getStateHelper().put(PropertyKeys.tip, tip);
226   }
227 
228   /**
229   This value will usually be set by the layout manager.
230 
231   */
232   public org.apache.myfaces.tobago.layout.Measure getHeight() {
233     Object object = getStateHelper().eval(PropertyKeys.height);
234     if (object != null) {
235        return Measure.valueOf(object);
236     }
237     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getHeight(getFacesContext(), this) : Measure.ZERO;
238   }
239 
240   public void setHeight(org.apache.myfaces.tobago.layout.Measure height) {
241     getStateHelper().put(PropertyKeys.height, height);
242   }
243 
244   public org.apache.myfaces.tobago.layout.Measure getMinimumWidth() {
245     Object object = getStateHelper().eval(PropertyKeys.minimumWidth);
246     if (object != null) {
247        return Measure.valueOf(object);
248     }
249     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumWidth(getFacesContext(), this) : Measure.ZERO;
250   }
251 
252   public void setMinimumWidth(org.apache.myfaces.tobago.layout.Measure minimumWidth) {
253     getStateHelper().put(PropertyKeys.minimumWidth, minimumWidth);
254   }
255 
256   /**
257   Flag indicating this component should rendered as an inline element.
258   <br />Default: <code>false</code>
259   @deprecated*/
260   @Deprecated
261   public boolean isInline() {
262     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.inline);
263     if (bool != null) {
264       return bool;
265     }
266     return false;
267   }
268 
269   @Deprecated
270   public void setInline(boolean inline) {
271       Deprecation.LOG.error("The attribute 'inline' of 'UILink' is deprecated. "
272           + "Please refer the documentation for further information.");
273     getStateHelper().put(PropertyKeys.inline, inline);
274   }
275 
276   public java.lang.Integer getRowSpan() {
277     Number value  = (Number) getStateHelper().eval(PropertyKeys.rowSpan);
278     if (value != null) {
279       return value.intValue();
280     }
281     return 1;
282   }
283 
284   public void setRowSpan(java.lang.Integer rowSpan) {
285     getStateHelper().put(PropertyKeys.rowSpan, rowSpan);
286   }
287 
288   /**
289   This value will usually be set by the layout manager.
290 
291   */
292   public org.apache.myfaces.tobago.layout.Measure getLeft() {
293     Object object = getStateHelper().eval(PropertyKeys.left);
294     if (object != null) {
295        return Measure.valueOf(object);
296     }
297     return null;
298   }
299 
300   public void setLeft(org.apache.myfaces.tobago.layout.Measure left) {
301     getStateHelper().put(PropertyKeys.left, left);
302   }
303 
304   public java.lang.Integer getColumnSpan() {
305     Number value  = (Number) getStateHelper().eval(PropertyKeys.columnSpan);
306     if (value != null) {
307       return value.intValue();
308     }
309     return 1;
310   }
311 
312   public void setColumnSpan(java.lang.Integer columnSpan) {
313     getStateHelper().put(PropertyKeys.columnSpan, columnSpan);
314   }
315 
316   /**
317   This value will usually be set by the layout manager.
318 
319   */
320   public org.apache.myfaces.tobago.layout.Measure getTop() {
321     Object object = getStateHelper().eval(PropertyKeys.top);
322     if (object != null) {
323        return Measure.valueOf(object);
324     }
325     return null;
326   }
327 
328   public void setTop(org.apache.myfaces.tobago.layout.Measure top) {
329     getStateHelper().put(PropertyKeys.top, top);
330   }
331 
332   public org.apache.myfaces.tobago.layout.Measure getMaximumHeight() {
333     Object object = getStateHelper().eval(PropertyKeys.maximumHeight);
334     if (object != null) {
335        return Measure.valueOf(object);
336     }
337     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumHeight(getFacesContext(), this) : Measure.ZERO;
338   }
339 
340   public void setMaximumHeight(org.apache.myfaces.tobago.layout.Measure maximumHeight) {
341     getStateHelper().put(PropertyKeys.maximumHeight, maximumHeight);
342   }
343 
344   /**
345   This value will usually be set by the layout manager. It holds the current width computed by the layout manager.
346 
347   */
348   public org.apache.myfaces.tobago.layout.Measure getCurrentWidth() {
349     Object object = getStateHelper().eval(PropertyKeys.currentWidth);
350     if (object != null) {
351        return Measure.valueOf(object);
352     }
353     return getWidth();
354   }
355 
356   public void setCurrentWidth(org.apache.myfaces.tobago.layout.Measure currentWidth) {
357     getStateHelper().put(PropertyKeys.currentWidth, currentWidth);
358   }
359 
360   public org.apache.myfaces.tobago.layout.Measure getMarginTop() {
361     Object object = getStateHelper().eval(PropertyKeys.marginTop);
362     if (object != null) {
363        return Measure.valueOf(object);
364     }
365     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this) : Measure.ZERO;
366   }
367 
368   public void setMarginTop(org.apache.myfaces.tobago.layout.Measure marginTop) {
369     getStateHelper().put(PropertyKeys.marginTop, marginTop);
370   }
371 
372   /**
373   This value will usually be set by the layout manager.
374 
375   */
376   public org.apache.myfaces.tobago.layout.Measure getWidth() {
377     Object object = getStateHelper().eval(PropertyKeys.width);
378     if (object != null) {
379        return Measure.valueOf(object);
380     }
381     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getWidth(getFacesContext(), this) : Measure.ZERO;
382   }
383 
384   public void setWidth(org.apache.myfaces.tobago.layout.Measure width) {
385     getStateHelper().put(PropertyKeys.width, width);
386   }
387 
388   public org.apache.myfaces.tobago.layout.Measure getMarginRight() {
389     Object object = getStateHelper().eval(PropertyKeys.marginRight);
390     if (object != null) {
391        return Measure.valueOf(object);
392     }
393     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this) : Measure.ZERO;
394   }
395 
396   public void setMarginRight(org.apache.myfaces.tobago.layout.Measure marginRight) {
397     getStateHelper().put(PropertyKeys.marginRight, marginRight);
398   }
399 
400   public org.apache.myfaces.tobago.layout.Measure getPreferredHeight() {
401     Object object = getStateHelper().eval(PropertyKeys.preferredHeight);
402     if (object != null) {
403        return Measure.valueOf(object);
404     }
405     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredHeight(getFacesContext(), this) : Measure.ZERO;
406   }
407 
408   public void setPreferredHeight(org.apache.myfaces.tobago.layout.Measure preferredHeight) {
409     getStateHelper().put(PropertyKeys.preferredHeight, preferredHeight);
410   }
411 
412   /**
413   Flag indicating that the resource referenced by the resource attribute is a jsf resource.
414    That means that the url has to be processed to change the prefix or suffix (e. g. *.jsf or
415    /faces/*). Default is false.
416   <br />Default: <code>false</code>
417   */
418   public boolean isJsfResource() {
419     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.jsfResource);
420     if (bool != null) {
421       return bool;
422     }
423     return false;
424   }
425 
426   public void setJsfResource(boolean jsfResource) {
427     getStateHelper().put(PropertyKeys.jsfResource, jsfResource);
428   }
429 
430   /**
431   Link to an internal resource.
432    Resources will be processed by the resource management.
433    E. g. define help.html and it will be served help_es.html or help_de.html if available.
434    For JSF-Pages you have to set the jsfResource attribute.
435 
436   */
437   public java.lang.String getResource() {
438     return (java.lang.String) getStateHelper().eval(PropertyKeys.resource);
439   }
440 
441   public void setResource(java.lang.String resource) {
442     getStateHelper().put(PropertyKeys.resource, resource);
443   }
444 
445   /**
446   This value will usually be set by the layout manager. It holds the current height computed by the layout manager.
447 
448   */
449   public org.apache.myfaces.tobago.layout.Measure getCurrentHeight() {
450     Object object = getStateHelper().eval(PropertyKeys.currentHeight);
451     if (object != null) {
452        return Measure.valueOf(object);
453     }
454     return getHeight();
455   }
456 
457   public void setCurrentHeight(org.apache.myfaces.tobago.layout.Measure currentHeight) {
458     getStateHelper().put(PropertyKeys.currentHeight, currentHeight);
459   }
460 
461   /**
462   Specify, if the command calls an JSF-Action.
463    Useful to switch off the Double-Submit-Check and Waiting-Behavior.
464   <br />Default: <code>true</code>
465   */
466   public boolean isTransition() {
467     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.transition);
468     if (bool != null) {
469       return bool;
470     }
471     return true;
472   }
473 
474   public void setTransition(boolean transition) {
475     getStateHelper().put(PropertyKeys.transition, transition);
476   }
477 
478   /**
479   Url to an image to display.
480 
481   */
482   public java.lang.String getImage() {
483     return (java.lang.String) getStateHelper().eval(PropertyKeys.image);
484   }
485 
486   public void setImage(java.lang.String image) {
487     getStateHelper().put(PropertyKeys.image, image);
488   }
489 
490   /**
491   This attribute is for internal use only.
492 
493   */
494   public org.apache.myfaces.tobago.layout.Display getDisplay() {
495     return (org.apache.myfaces.tobago.layout.Display) getStateHelper().eval(PropertyKeys.display);
496   }
497 
498   public void setDisplay(org.apache.myfaces.tobago.layout.Display display) {
499     getStateHelper().put(PropertyKeys.display, display);
500   }
501 
502   /**
503   Text value to display as label.
504    If text contains an underscore the next character is used as accesskey.
505 
506   */
507   public java.lang.String getLabel() {
508     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
509   }
510 
511   public void setLabel(java.lang.String label) {
512     getStateHelper().put(PropertyKeys.label, label);
513   }
514 
515   public org.apache.myfaces.tobago.layout.Measure getMaximumWidth() {
516     Object object = getStateHelper().eval(PropertyKeys.maximumWidth);
517     if (object != null) {
518        return Measure.valueOf(object);
519     }
520     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this) : Measure.ZERO;
521   }
522 
523   public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
524     getStateHelper().put(PropertyKeys.maximumWidth, maximumWidth);
525   }
526 
527   public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
528     Object object = getStateHelper().eval(PropertyKeys.preferredWidth);
529     if (object != null) {
530        return Measure.valueOf(object);
531     }
532     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this) : Measure.ZERO;
533   }
534 
535   public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
536     getStateHelper().put(PropertyKeys.preferredWidth, preferredWidth);
537   }
538 
539   public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
540     Object object = getStateHelper().eval(PropertyKeys.marginBottom);
541     if (object != null) {
542        return Measure.valueOf(object);
543     }
544     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this) : Measure.ZERO;
545   }
546 
547   public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
548     getStateHelper().put(PropertyKeys.marginBottom, marginBottom);
549   }
550 
551   /**
552   This attribute is for internal use only.
553 
554   */
555   public java.lang.Integer getVerticalIndex() {
556     Number value  = (Number) getStateHelper().eval(PropertyKeys.verticalIndex);
557     if (value != null) {
558       return value.intValue();
559     }
560     return null;
561   }
562 
563   public void setVerticalIndex(java.lang.Integer verticalIndex) {
564     getStateHelper().put(PropertyKeys.verticalIndex, verticalIndex);
565   }
566 
567   /**
568   Flag indicating that the action of this element, will not be executed from client side
569    (e. g. when the user clicks a button.
570    When setting this value to true, the action will not be executed by the Tobago, but it can executed
571    by JavaScript.
572    This attribute is useful, when you want to add JavaScript event handlers to commands manually.
573    In this case you usually don't want a submit with a full reload of the page.
574   <br />Default: <code>false</code>
575   */
576   public boolean isOmit() {
577     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.omit);
578     if (bool != null) {
579       return bool;
580     }
581     return false;
582   }
583 
584   public void setOmit(boolean omit) {
585     getStateHelper().put(PropertyKeys.omit, omit);
586   }
587 
588   /**
589   Indicate the partially rendered Components in a case of a submit.
590 
591   */
592   public String[] getRenderedPartially() {
593     Object strArray = getStateHelper().eval(PropertyKeys.renderedPartially);
594     if (strArray != null) {
595       if (strArray instanceof String[]) {
596         return (String[]) strArray;
597       } else if (strArray instanceof String) {
598         String[] strings = StringUtils.split((String) strArray, ", ");
599         List<String> result = new ArrayList<String>(strings.length);
600         for (String string : strings) {
601           if (string.trim().length() != 0) {
602             result.add(string.trim());
603           }
604         }
605         return result.toArray(new String[result.size()]);
606       } else if (strArray == null) {
607         return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
608       } else {
609         return new String[]{strArray.toString()};
610       }
611     }
612     return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
613   }
614 
615   public void setRenderedPartially(String[] renderedPartially) {
616     getStateHelper().put(PropertyKeys.renderedPartially, renderedPartially);
617   }
618 
619   /**
620   Name of a frame where the resource retrieved via this hyperlink is to be
621    displayed.
622 
623   */
624   public java.lang.String getTarget() {
625     return (java.lang.String) getStateHelper().eval(PropertyKeys.target);
626   }
627 
628   public void setTarget(java.lang.String target) {
629     getStateHelper().put(PropertyKeys.target, target);
630   }
631 
632   public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
633     if (currentMarkup != null) {
634       return currentMarkup;
635     }
636     return null;
637   }
638 
639   public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
640     this.currentMarkup = currentMarkup;
641   }
642 
643   /**
644   Script to be invoked when clicked
645 
646   */
647   public java.lang.String getOnclick() {
648     return (java.lang.String) getStateHelper().eval(PropertyKeys.onclick);
649   }
650 
651   public void setOnclick(java.lang.String onclick) {
652     getStateHelper().put(PropertyKeys.onclick, onclick);
653   }
654 
655   /**
656   This attribute is for internal use only.
657 
658   */
659   public java.lang.Integer getHorizontalIndex() {
660     Number value  = (Number) getStateHelper().eval(PropertyKeys.horizontalIndex);
661     if (value != null) {
662       return value.intValue();
663     }
664     return null;
665   }
666 
667   public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
668     getStateHelper().put(PropertyKeys.horizontalIndex, horizontalIndex);
669   }
670 
671   /**
672   Flag indicating that this element is disabled.
673   <br />Default: <code>false</code>
674   */
675   public boolean isDisabled() {
676     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
677     if (bool != null) {
678       return bool;
679     }
680     return false;
681   }
682 
683   public void setDisabled(boolean disabled) {
684     getStateHelper().put(PropertyKeys.disabled, disabled);
685   }
686 
687   public Object saveState(FacesContext context) {
688     currentMarkup = null;
689     return super.saveState(context);
690   }
691 
692 
693 }