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