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