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.AbstractUIToolBarSelectOne;
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 set of radio command button's within a toolbar.
42    * UIComponent class, generated from template {@code component2.0.stg} with class
43    * {@link org.apache.myfaces.tobago.internal.taglib.component.ToolBarSelectOneTagDeclaration}.
44   */
45  public class UIToolBarSelectOne
46      extends AbstractUIToolBarSelectOne implements SupportsMarkup {
47  
48    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.ToolBarSelectOne";
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      marginLeft,
57      link,
58      minimumHeight,
59      height,
60      minimumWidth,
61      rowSpan,
62      left,
63      columnSpan,
64      top,
65      maximumHeight,
66      currentWidth,
67      marginTop,
68      width,
69      marginRight,
70      jsfResource,
71      resource,
72      currentHeight,
73      preferredHeight,
74      transition,
75      display,
76      label,
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>Starts with protocol followed by 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   /**
396   Text value to display as label.
397    If text contains an underscore the next character is used as accesskey (if configured so and possible).
398 
399   */
400   public java.lang.String getLabel() {
401     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
402   }
403 
404   public void setLabel(java.lang.String label) {
405     getStateHelper().put(PropertyKeys.label, label);
406   }
407 
408   public org.apache.myfaces.tobago.layout.Measure getMaximumWidth() {
409     Object object = getStateHelper().eval(PropertyKeys.maximumWidth);
410     if (object != null) {
411        return Measure.valueOf(object);
412     }
413     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this) : Measure.ZERO;
414   }
415 
416   public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
417     getStateHelper().put(PropertyKeys.maximumWidth, maximumWidth);
418   }
419 
420   public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
421     Object object = getStateHelper().eval(PropertyKeys.preferredWidth);
422     if (object != null) {
423        return Measure.valueOf(object);
424     }
425     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this) : Measure.ZERO;
426   }
427 
428   public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
429     getStateHelper().put(PropertyKeys.preferredWidth, preferredWidth);
430   }
431 
432   public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
433     Object object = getStateHelper().eval(PropertyKeys.marginBottom);
434     if (object != null) {
435        return Measure.valueOf(object);
436     }
437     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this) : Measure.ZERO;
438   }
439 
440   public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
441     getStateHelper().put(PropertyKeys.marginBottom, marginBottom);
442   }
443 
444   /**
445   This attribute is for internal use only.
446 
447   */
448   public java.lang.Integer getVerticalIndex() {
449     Number value  = (Number) getStateHelper().eval(PropertyKeys.verticalIndex);
450     if (value != null) {
451       return value.intValue();
452     }
453     return null;
454   }
455 
456   public void setVerticalIndex(java.lang.Integer verticalIndex) {
457     getStateHelper().put(PropertyKeys.verticalIndex, verticalIndex);
458   }
459 
460   /**
461   Flag indicating that the action of this element, will not be executed from client side
462    (e. g. when the user clicks a button.
463    When setting this value to true, the action will not be executed by the Tobago, but it can executed
464    by JavaScript.
465    This attribute is useful, when you want to add JavaScript event handlers to commands manually.
466    In this case you usually don't want a submit with a full reload of the page.
467   <br />Default: <code>false</code>
468   */
469   public boolean isOmit() {
470     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.omit);
471     if (bool != null) {
472       return bool;
473     }
474     return false;
475   }
476 
477   public void setOmit(boolean omit) {
478     getStateHelper().put(PropertyKeys.omit, omit);
479   }
480 
481   public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
482     if (currentMarkup != null) {
483       return currentMarkup;
484     }
485     return null;
486   }
487 
488   public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
489     this.currentMarkup = currentMarkup;
490   }
491 
492   /**
493   <p>
494    Indicate the partially rendered components in a case of a submit.
495    </p>
496    <p>
497    The search depends on the number of prefixed colons in the relativeId:
498    <dl>
499      <dd>number of prefixed colons == 0</dd>
500      <dt>fully relative</dt>
501      <dd>number of prefixed colons == 1</dd>
502      <dt>absolute (still normal findComponent syntax)</dt>
503      <dd>number of prefixed colons == 2</dd>
504      <dt>search in the current naming container (same as 0 colons)</dt>
505      <dd>number of prefixed colons == 3</dd>
506      <dt>search in the parent naming container of the current naming container</dt>
507      <dd>number of prefixed colons > 3</dd>
508      <dt>go to the next parent naming container for each additional colon</dt>
509    </dl>
510    </p>
511    <p>
512    If a literal is specified: to use more than one identifier the identifiers must be space delimited.
513    </p>
514    <p>
515    Using this in a UISheet or UITabGroup component this list indicates components to update when calling
516    internal AJAX requests like sort or paging commands.
517    Don't forget to add the sheet-id or tagGroup-id in that case, if needed.
518    </p>
519    <p>
520    You can also use
521 
522   */
523   public String[] getRenderedPartially() {
524     Object strArray = getStateHelper().eval(PropertyKeys.renderedPartially);
525     if (strArray != null) {
526       if (strArray instanceof String[]) {
527         return (String[]) strArray;
528       } else if (strArray instanceof String) {
529         String[] strings = StringUtils.split((String) strArray, ", ");
530         List<String> result = new ArrayList<String>(strings.length);
531         for (String string : strings) {
532           if (string.trim().length() != 0) {
533             result.add(string.trim());
534           }
535         }
536         return result.toArray(new String[result.size()]);
537       } else if (strArray == null) {
538         return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
539       } else {
540         return new String[]{strArray.toString()};
541       }
542     }
543     return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
544   }
545 
546   public void setRenderedPartially(String[] renderedPartially) {
547     getStateHelper().put(PropertyKeys.renderedPartially, renderedPartially);
548   }
549 
550   /**
551   Name of a frame where the resource retrieved via this hyperlink is to be
552    displayed.
553 
554   */
555   public java.lang.String getTarget() {
556     return (java.lang.String) getStateHelper().eval(PropertyKeys.target);
557   }
558 
559   public void setTarget(java.lang.String target) {
560     getStateHelper().put(PropertyKeys.target, target);
561   }
562 
563   /**
564   Script to be invoked when clicked
565 
566   */
567   public java.lang.String getOnclick() {
568     return (java.lang.String) getStateHelper().eval(PropertyKeys.onclick);
569   }
570 
571   public void setOnclick(java.lang.String onclick) {
572     getStateHelper().put(PropertyKeys.onclick, onclick);
573   }
574 
575   /**
576   This attribute is for internal use only.
577 
578   */
579   public java.lang.Integer getHorizontalIndex() {
580     Number value  = (Number) getStateHelper().eval(PropertyKeys.horizontalIndex);
581     if (value != null) {
582       return value.intValue();
583     }
584     return null;
585   }
586 
587   public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
588     getStateHelper().put(PropertyKeys.horizontalIndex, horizontalIndex);
589   }
590 
591   /**
592   Flag indicating that this element is disabled.
593   <br />Default: <code>false</code>
594   */
595   public boolean isDisabled() {
596     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
597     if (bool != null) {
598       return bool;
599     }
600     return false;
601   }
602 
603   public void setDisabled(boolean disabled) {
604     getStateHelper().put(PropertyKeys.disabled, disabled);
605   }
606 
607   public Object saveState(FacesContext context) {
608     currentMarkup = null;
609     return super.saveState(context);
610   }
611 
612 }