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