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