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