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.AbstractUITreeCommand;
25  import org.apache.myfaces.tobago.layout.Display;
26  import org.apache.myfaces.tobago.layout.LayoutBase;
27  import org.apache.myfaces.tobago.layout.Measure;
28  import org.apache.myfaces.tobago.internal.util.ArrayUtils;
29  import org.apache.myfaces.tobago.internal.util.StringUtils;
30  import org.apache.myfaces.tobago.internal.util.Deprecation;
31  import org.apache.myfaces.tobago.renderkit.MarginValues;
32  import org.apache.myfaces.tobago.renderkit.SpacingValues;
33  import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
34  import javax.el.ELException;
35  import javax.faces.FacesException;
36  import java.util.ArrayList;
37  import java.util.List;
38  import javax.el.MethodExpression;
39  import javax.el.ValueExpression;
40  
41  /** 
42   Renders a command inside of a tree.
43    * UIComponent class, generated from template {@code component2.0.stg} with class
44    * {@link org.apache.myfaces.tobago.internal.taglib.component.TreeCommandTagDeclaration}.
45   */
46  public class UITreeCommand
47      extends AbstractUITreeCommand implements LayoutBase, SupportsAccessKey, SupportsMarkup {
48  
49    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.TreeCommand";
50  
51    public static final String COMPONENT_FAMILY = "javax.faces.Command";
52  
53    private org.apache.myfaces.tobago.context.Markup currentMarkup;
54  
55    enum PropertyKeys {
56      accessKey,
57      markup,
58      marginLeft,
59      link,
60      tabIndex,
61      minimumHeight,
62      tip,
63      height,
64      minimumWidth,
65      rowSpan,
66      left,
67      columnSpan,
68      top,
69      maximumHeight,
70      currentWidth,
71      marginTop,
72      width,
73      marginRight,
74      preferredHeight,
75      jsfResource,
76      resource,
77      currentHeight,
78      transition,
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   This attribute is for internal use only.
436 
437   */
438   public org.apache.myfaces.tobago.layout.Display getDisplay() {
439     return (org.apache.myfaces.tobago.layout.Display) getStateHelper().eval(PropertyKeys.display);
440   }
441 
442   public void setDisplay(org.apache.myfaces.tobago.layout.Display display) {
443     getStateHelper().put(PropertyKeys.display, display);
444   }
445 
446   /**
447   Text value to display as label.
448    If text contains an underscore the next character is used as accesskey (if configured so and possible).
449 
450   */
451   public java.lang.String getLabel() {
452     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
453   }
454 
455   public void setLabel(java.lang.String label) {
456     getStateHelper().put(PropertyKeys.label, label);
457   }
458 
459   public org.apache.myfaces.tobago.layout.Measure getMaximumWidth() {
460     Object object = getStateHelper().eval(PropertyKeys.maximumWidth);
461     if (object != null) {
462        return Measure.valueOf(object);
463     }
464     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this) : Measure.ZERO;
465   }
466 
467   public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
468     getStateHelper().put(PropertyKeys.maximumWidth, maximumWidth);
469   }
470 
471   public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
472     Object object = getStateHelper().eval(PropertyKeys.preferredWidth);
473     if (object != null) {
474        return Measure.valueOf(object);
475     }
476     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this) : Measure.ZERO;
477   }
478 
479   public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
480     getStateHelper().put(PropertyKeys.preferredWidth, preferredWidth);
481   }
482 
483   public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
484     Object object = getStateHelper().eval(PropertyKeys.marginBottom);
485     if (object != null) {
486        return Measure.valueOf(object);
487     }
488     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this) : Measure.ZERO;
489   }
490 
491   public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
492     getStateHelper().put(PropertyKeys.marginBottom, marginBottom);
493   }
494 
495   /**
496   This attribute is for internal use only.
497 
498   */
499   public java.lang.Integer getVerticalIndex() {
500     Number value  = (Number) getStateHelper().eval(PropertyKeys.verticalIndex);
501     if (value != null) {
502       return value.intValue();
503     }
504     return null;
505   }
506 
507   public void setVerticalIndex(java.lang.Integer verticalIndex) {
508     getStateHelper().put(PropertyKeys.verticalIndex, verticalIndex);
509   }
510 
511   /**
512   Flag indicating that the action of this element, will not be executed from client side
513    (e. g. when the user clicks a button.
514    When setting this value to true, the action will not be executed by the Tobago, but it can executed
515    by JavaScript.
516    This attribute is useful, when you want to add JavaScript event handlers to commands manually.
517    In this case you usually don't want a submit with a full reload of the page.
518   <br />Default: <code>false</code>
519   */
520   public boolean isOmit() {
521     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.omit);
522     if (bool != null) {
523       return bool;
524     }
525     return false;
526   }
527 
528   public void setOmit(boolean omit) {
529     getStateHelper().put(PropertyKeys.omit, omit);
530   }
531 
532   /**
533   <p>
534    Indicate the partially rendered components in a case of a submit.
535    </p>
536    <p>
537    The search depends on the number of prefixed colons in the relativeId:
538    <dl>
539      <dd>number of prefixed colons == 0</dd>
540      <dt>fully relative</dt>
541      <dd>number of prefixed colons == 1</dd>
542      <dt>absolute (still normal findComponent syntax)</dt>
543      <dd>number of prefixed colons == 2</dd>
544      <dt>search in the current naming container (same as 0 colons)</dt>
545      <dd>number of prefixed colons == 3</dd>
546      <dt>search in the parent naming container of the current naming container</dt>
547      <dd>number of prefixed colons > 3</dd>
548      <dt>go to the next parent naming container for each additional colon</dt>
549    </dl>
550    </p>
551    <p>
552    If a literal is specified: to use more than one identifier the identifiers must be space delimited.
553    </p>
554    <p>
555    Using this in a UISheet or UITabGroup component this list indicates components to update when calling
556    internal AJAX requests like sort or paging commands.
557    Don't forget to add the sheet-id or tagGroup-id in that case, if needed.
558    </p>
559    <p>
560    You can also use
561 
562   */
563   public String[] getRenderedPartially() {
564     Object strArray = getStateHelper().eval(PropertyKeys.renderedPartially);
565     if (strArray != null) {
566       if (strArray instanceof String[]) {
567         return (String[]) strArray;
568       } else if (strArray instanceof String) {
569         String[] strings = StringUtils.split((String) strArray, ", ");
570         List<String> result = new ArrayList<String>(strings.length);
571         for (String string : strings) {
572           if (string.trim().length() != 0) {
573             result.add(string.trim());
574           }
575         }
576         return result.toArray(new String[result.size()]);
577       } else if (strArray == null) {
578         return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
579       } else {
580         return new String[]{strArray.toString()};
581       }
582     }
583     return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
584   }
585 
586   public void setRenderedPartially(String[] renderedPartially) {
587     getStateHelper().put(PropertyKeys.renderedPartially, renderedPartially);
588   }
589 
590   /**
591   Name of a frame where the resource retrieved via this hyperlink is to be
592    displayed.
593 
594   */
595   public java.lang.String getTarget() {
596     return (java.lang.String) getStateHelper().eval(PropertyKeys.target);
597   }
598 
599   public void setTarget(java.lang.String target) {
600     getStateHelper().put(PropertyKeys.target, target);
601   }
602 
603   public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
604     if (currentMarkup != null) {
605       return currentMarkup;
606     }
607     return null;
608   }
609 
610   public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
611     this.currentMarkup = currentMarkup;
612   }
613 
614   /**
615   Script to be invoked when clicked
616 
617   */
618   public java.lang.String getOnclick() {
619     return (java.lang.String) getStateHelper().eval(PropertyKeys.onclick);
620   }
621 
622   public void setOnclick(java.lang.String onclick) {
623     getStateHelper().put(PropertyKeys.onclick, onclick);
624   }
625 
626   /**
627   This attribute is for internal use only.
628 
629   */
630   public java.lang.Integer getHorizontalIndex() {
631     Number value  = (Number) getStateHelper().eval(PropertyKeys.horizontalIndex);
632     if (value != null) {
633       return value.intValue();
634     }
635     return null;
636   }
637 
638   public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
639     getStateHelper().put(PropertyKeys.horizontalIndex, horizontalIndex);
640   }
641 
642   /**
643   Flag indicating that this element is disabled.
644   <br />Default: <code>false</code>
645   */
646   public boolean isDisabled() {
647     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
648     if (bool != null) {
649       return bool;
650     }
651     return false;
652   }
653 
654   public void setDisabled(boolean disabled) {
655     getStateHelper().put(PropertyKeys.disabled, disabled);
656   }
657 
658   public Object saveState(FacesContext context) {
659     currentMarkup = null;
660     return super.saveState(context);
661   }
662 
663 }