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