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.el.MethodExpression;
23  import javax.faces.component.ActionSource2;
24  import javax.faces.context.FacesContext;
25  import org.apache.myfaces.tobago.context.Markup;
26  import org.apache.myfaces.tobago.internal.component.AbstractUITabGroup;
27  import org.apache.myfaces.tobago.model.SwitchType;
28  import org.apache.myfaces.tobago.renderkit.css.CustomClass;
29  import org.apache.myfaces.tobago.renderkit.css.Style;
30  import org.apache.myfaces.tobago.internal.util.ArrayUtils;
31  import org.apache.myfaces.tobago.internal.util.StringUtils;
32  import org.apache.myfaces.tobago.internal.util.Deprecation;
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 tab group which contains tab panels.
42    * UIComponent class, generated from template {@code component.stg} with class
43    * {@link org.apache.myfaces.tobago.internal.taglib.component.TabGroupTagDeclaration}.
44   */
45  public class UITabGroup
46      extends AbstractUITabGroup implements ActionSource2, Visual {
47  
48    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.TabGroup";
49  
50    public static final String COMPONENT_FAMILY = "javax.faces.Panel";
51  
52  
53    enum PropertyKeys {
54      renderedIndex,
55      switchType,
56      tabChangeListener,
57      markup,
58      renderedPartially,
59      selectedIndex,
60      actionListener,
61      immediate,
62      action,
63      customClass,
64      showNavigationBar,
65      style,
66      tip,
67    }
68  
69    public String getFamily() {
70      return COMPONENT_FAMILY;
71    }
72  
73  
74    /**
75    For internal use. TBD: Check if this is needed any longer.
76    <br>Default: <code>0</code>
77    */
78    public java.lang.Integer getRenderedIndex() {
79      Number value  = (Number) getStateHelper().eval(PropertyKeys.renderedIndex);
80      if (value != null) {
81        return value.intValue();
82      }
83      return 0;
84    }
85  
86    public void setRenderedIndex(java.lang.Integer renderedIndex) {
87      getStateHelper().put(PropertyKeys.renderedIndex, renderedIndex);
88    }
89  
90    /**
91    <p>
92     Indicating how tab switching should be done.
93     </p>
94     <p>
95     Possible values are:
96     </p>
97     <dl>
98       <dt>client</dt>
99       <dd>Tab switching is done on client, no server Request.</dd>
100      <dt>reloadPage</dt>
101      <dd>Tab switching is done by server request. Full page is reloaded.</dd>
102      <dt>reloadTab</dt>
103      <dd>Tab switching is done by server request. Only the Tab is reloaded.</dd>
104    </dl>
105   <br>Default: <code>client</code><br>Allowed Values: <code>client,reloadPage,reloadTab</code>
106   */
107   public org.apache.myfaces.tobago.model.SwitchType getSwitchType() {
108     org.apache.myfaces.tobago.model.SwitchType switchType = (org.apache.myfaces.tobago.model.SwitchType) getStateHelper().eval(PropertyKeys.switchType);
109     if (switchType != null) {
110       return switchType;
111     }
112     return org.apache.myfaces.tobago.model.SwitchType.client;
113   }
114 
115   public void setSwitchType(org.apache.myfaces.tobago.model.SwitchType switchType) {
116     getStateHelper().put(PropertyKeys.switchType, switchType);
117   }
118 
119   /**
120    * @deprecated since 2.0.0
121    */
122   @Deprecated
123   public javax.faces.el.MethodBinding getTabChangeListener() {
124     javax.el.MethodExpression expression = getTabChangeListenerExpression();
125     if (expression instanceof MethodBindingToMethodExpression) {
126       return ((MethodBindingToMethodExpression)expression).getMethodBinding();
127     }
128     if (expression != null) {
129        return new MethodExpressionToMethodBinding(expression);
130     }
131     return null;
132   }
133 
134   /**
135    * @deprecated since 2.0.0
136    */
137   @Deprecated
138   public void setTabChangeListener(javax.faces.el.MethodBinding tabChangeListener) {
139     if (tabChangeListener != null) {
140       setTabChangeListenerExpression(new MethodBindingToMethodExpression(tabChangeListener));
141     } else {
142       setTabChangeListenerExpression(null);
143     }
144   }
145 
146   public javax.el.MethodExpression getTabChangeListenerExpression() {
147     return (javax.el.MethodExpression) getStateHelper().eval(PropertyKeys.tabChangeListener);
148   }
149 
150   public void setTabChangeListenerExpression(javax.el.MethodExpression tabChangeListener) {
151     getStateHelper().put(PropertyKeys.tabChangeListener, tabChangeListener);
152   }
153 
154 
155   public org.apache.myfaces.tobago.context.Markup getMarkup() {
156     Object object = getStateHelper().eval(PropertyKeys.markup);
157     if (object != null) {
158       return Markup.valueOf(object);
159     }
160     return null;
161   }
162 
163   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
164     getStateHelper().put(PropertyKeys.markup, markup);
165   }
166 
167   /**
168   <p>
169    Indicate the partially rendered components in a case of a submit.
170    </p>
171    <p>
172    The search depends on the number of prefixed colons in the relativeId:
173    </p>
174    <dl>
175      <dd>number of prefixed colons == 0</dd>
176      <dt>fully relative</dt>
177      <dd>number of prefixed colons == 1</dd>
178      <dt>absolute (still normal findComponent syntax)</dt>
179      <dd>number of prefixed colons == 2</dd>
180      <dt>search in the current naming container (same as 0 colons)</dt>
181      <dd>number of prefixed colons == 3</dd>
182      <dt>search in the parent naming container of the current naming container</dt>
183      <dd>number of prefixed colons &gt; 3</dd>
184      <dt>go to the next parent naming container for each additional colon</dt>
185    </dl>
186    <p>
187    If a literal is specified: to use more than one identifier the identifiers must be space delimited.
188    </p>
189    <p>
190    Using this in a UISheet or UITabGroup component this list indicates components to update when calling
191    internal AJAX requests like sort or paging commands.
192    Don't forget to add the sheet-id or tagGroup-id in that case, if needed.
193    </p>
194    <p>
195    You can also use
196 
197   */
198   public String[] getRenderedPartially() {
199     Object strArray = getStateHelper().eval(PropertyKeys.renderedPartially);
200     if (strArray != null) {
201       if (strArray instanceof String[]) {
202         return (String[]) strArray;
203       } else if (strArray instanceof String) {
204         String[] strings = StringUtils.split((String) strArray, ", ");
205         List<String> result = new ArrayList<String>(strings.length);
206         for (String string : strings) {
207           if (string.trim().length() != 0) {
208             result.add(string.trim());
209           }
210         }
211         return result.toArray(new String[result.size()]);
212       } else if (strArray == null) {
213         return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
214       } else {
215         return new String[]{strArray.toString()};
216       }
217     }
218     return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
219   }
220 
221   public void setRenderedPartially(String[] renderedPartially) {
222     getStateHelper().put(PropertyKeys.renderedPartially, renderedPartially);
223   }
224 
225   /**
226   <strong>ValueBindingExpression</strong> pointing to a Integer to save the
227    component's selected Tab.
228   <br>Default: <code>0</code>
229   */
230   public java.lang.Integer getSelectedIndex() {
231     Number value  = (Number) getStateHelper().eval(PropertyKeys.selectedIndex);
232     if (value != null) {
233       return value.intValue();
234     }
235     return 0;
236   }
237 
238   public void setSelectedIndex(java.lang.Integer selectedIndex) {
239     getStateHelper().put(PropertyKeys.selectedIndex, selectedIndex);
240   }
241 
242   /**
243    * @deprecated since 2.0.0
244    */
245   @Deprecated
246   public javax.faces.el.MethodBinding getActionListener() {
247     javax.el.MethodExpression expression = getActionListenerExpression();
248     if (expression instanceof MethodBindingToMethodExpression) {
249       return ((MethodBindingToMethodExpression)expression).getMethodBinding();
250     }
251     if (expression != null) {
252        return new MethodExpressionToMethodBinding(expression);
253     }
254     return null;
255   }
256 
257   /**
258    * @deprecated since 2.0.0
259    */
260   @Deprecated
261   public void setActionListener(javax.faces.el.MethodBinding actionListener) {
262     if (actionListener != null) {
263       setActionListenerExpression(new MethodBindingToMethodExpression(actionListener));
264     } else {
265       setActionListenerExpression(null);
266     }
267   }
268 
269   public javax.el.MethodExpression getActionListenerExpression() {
270     return (javax.el.MethodExpression) getStateHelper().eval(PropertyKeys.actionListener);
271   }
272 
273   public void setActionListenerExpression(javax.el.MethodExpression actionListener) {
274     getStateHelper().put(PropertyKeys.actionListener, actionListener);
275   }
276 
277 
278   /**
279   Flag indicating that, if this component is activated by the user,
280    notifications should be delivered to interested listeners and actions
281    immediately (that is, during Apply Request Values phase) rather than
282    waiting until Invoke Application phase.
283   <br>Default: <code>false</code>
284   */
285   public boolean isImmediate() {
286     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.immediate);
287     if (bool != null) {
288       return bool;
289     }
290     return false;
291   }
292 
293   public void setImmediate(boolean immediate) {
294     getStateHelper().put(PropertyKeys.immediate, immediate);
295   }
296 
297   /**
298    * @deprecated since 2.0.0
299    */
300   @Deprecated
301   public javax.faces.el.MethodBinding getAction() {
302     javax.el.MethodExpression expression = getActionExpression();
303     if (expression instanceof MethodBindingToMethodExpression) {
304       return ((MethodBindingToMethodExpression)expression).getMethodBinding();
305     }
306     if (expression != null) {
307        return new MethodExpressionToMethodBinding(expression);
308     }
309     return null;
310   }
311 
312   /**
313    * @deprecated since 2.0.0
314    */
315   @Deprecated
316   public void setAction(javax.faces.el.MethodBinding action) {
317     if (action != null) {
318       setActionExpression(new MethodBindingToMethodExpression(action));
319     } else {
320       setActionExpression(null);
321     }
322   }
323 
324   public javax.el.MethodExpression getActionExpression() {
325     return (javax.el.MethodExpression) getStateHelper().eval(PropertyKeys.action);
326   }
327 
328   public void setActionExpression(javax.el.MethodExpression action) {
329     getStateHelper().put(PropertyKeys.action, action);
330   }
331 
332 
333   /**
334   Sets a CSS class in its parent, if the parent supports it.
335 
336    Which this feature it is possible to put a CSS class name into a component with the &lt;tc:style&gt; tag. Example:
337 
338    <pre>
339    &lt;tc:in&gt;
340      &lt;tc:style customClass="my-emphasized"/&gt;
341    &lt;/tc:in&gt;
342    </pre>
343 
344    One capability is, to used external CSS libs.
345    <br>
346    This feature should not be used imprudent.
347    Because it might be unstable against changes in the renderered HTML code.
348 
349   */
350   public org.apache.myfaces.tobago.renderkit.css.CustomClass getCustomClass() {
351     return (org.apache.myfaces.tobago.renderkit.css.CustomClass) getStateHelper().eval(PropertyKeys.customClass);
352   }
353 
354   public void setCustomClass(org.apache.myfaces.tobago.renderkit.css.CustomClass customClass) {
355     getStateHelper().put(PropertyKeys.customClass, customClass);
356   }
357 
358   /**
359   Flag indicating that the tab navigation bar is rendered.
360   <br>Default: <code>true</code>
361   */
362   public boolean isShowNavigationBar() {
363     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.showNavigationBar);
364     if (bool != null) {
365       return bool;
366     }
367     return true;
368   }
369 
370   public void setShowNavigationBar(boolean showNavigationBar) {
371     getStateHelper().put(PropertyKeys.showNavigationBar, showNavigationBar);
372   }
373 
374   /**
375   For internal use. Used for rendering, if there is a child tag &lt;tc:style&gt;
376 
377   */
378   public org.apache.myfaces.tobago.renderkit.css.Style getStyle() {
379     return (org.apache.myfaces.tobago.renderkit.css.Style) getStateHelper().eval(PropertyKeys.style);
380   }
381 
382   public void setStyle(org.apache.myfaces.tobago.renderkit.css.Style style) {
383     getStateHelper().put(PropertyKeys.style, style);
384   }
385 
386   /**
387   Text value to display as tooltip.
388 
389   */
390   public java.lang.String getTip() {
391     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
392   }
393 
394   public void setTip(java.lang.String tip) {
395     getStateHelper().put(PropertyKeys.tip, tip);
396   }
397 
398 
399 }