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