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