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.Arrays;
36  import java.util.ArrayList;
37  import java.util.Collection;
38  import java.util.List;
39  import javax.el.MethodExpression;
40  import javax.el.ValueExpression;
41  
42  /** 
43   Renders a tab group which contains tab panels.
44    * UIComponent class, generated from template {@code component.stg} with class
45    * {@link org.apache.myfaces.tobago.internal.taglib.component.TabGroupTagDeclaration}.
46   */
47  public class UITabGroup
48      extends AbstractUITabGroup implements ActionSource2, Visual {
49  
50    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.TabGroup";
51  
52    public static final String COMPONENT_FAMILY = "javax.faces.Panel";
53  
54    private static final Collection<String> EVENT_NAMES = Arrays.asList("click");
55  
56    @Override
57    public Collection<String> getEventNames() {
58      return EVENT_NAMES;
59    }
60  
61    @Override
62    public String getDefaultEventName() {
63      return "click";
64    }
65  
66  
67    enum PropertyKeys {
68      renderedIndex,
69      actionListener,
70      switchType,
71      tabChangeListener,
72      markup,
73      immediate,
74      action,
75      customClass,
76      showNavigationBar,
77      style,
78      tip,
79      selectedIndex,
80    }
81  
82    public String getFamily() {
83      return COMPONENT_FAMILY;
84    }
85  
86  
87    /**
88    For internal use. TBD: Check if this is needed any longer.
89    <br>Default: <code>0</code>
90    */
91    public java.lang.Integer getRenderedIndex() {
92      Number value  = (Number) getStateHelper().eval(PropertyKeys.renderedIndex);
93      if (value != null) {
94        return value.intValue();
95      }
96      return 0;
97    }
98  
99    public void setRenderedIndex(java.lang.Integer renderedIndex) {
100     getStateHelper().put(PropertyKeys.renderedIndex, renderedIndex);
101   }
102 
103   /**
104    * @deprecated since 2.0.0
105    */
106   @Deprecated
107   public javax.faces.el.MethodBinding getActionListener() {
108     javax.el.MethodExpression expression = getActionListenerExpression();
109     if (expression instanceof MethodBindingToMethodExpression) {
110       return ((MethodBindingToMethodExpression)expression).getMethodBinding();
111     }
112     if (expression != null) {
113        return new MethodExpressionToMethodBinding(expression);
114     }
115     return null;
116   }
117 
118   /**
119    * @deprecated since 2.0.0
120    */
121   @Deprecated
122   public void setActionListener(javax.faces.el.MethodBinding actionListener) {
123     if (actionListener != null) {
124       setActionListenerExpression(new MethodBindingToMethodExpression(actionListener));
125     } else {
126       setActionListenerExpression(null);
127     }
128   }
129 
130   public javax.el.MethodExpression getActionListenerExpression() {
131     return (javax.el.MethodExpression) getStateHelper().eval(PropertyKeys.actionListener);
132   }
133 
134   public void setActionListenerExpression(javax.el.MethodExpression actionListener) {
135     getStateHelper().put(PropertyKeys.actionListener, actionListener);
136   }
137 
138 
139   /**
140   <p>
141    Indicating how tab switching should be done.
142    </p>
143    <p>
144    Possible values are:
145    </p>
146    <dl>
147      <dt>client</dt>
148      <dd>Tab switching is done on client, no server Request.</dd>
149      <dt>reloadPage</dt>
150      <dd>Tab switching is done by server request. Full page is reloaded.</dd>
151      <dt>reloadTab</dt>
152      <dd>Tab switching is done by server request. Only the Tab is reloaded.</dd>
153    </dl>
154   <br>Default: <code>client</code><br>Allowed Values: <code>client,reloadPage,reloadTab</code>
155   */
156   public org.apache.myfaces.tobago.model.SwitchType getSwitchType() {
157     org.apache.myfaces.tobago.model.SwitchType switchType = (org.apache.myfaces.tobago.model.SwitchType) getStateHelper().eval(PropertyKeys.switchType);
158     if (switchType != null) {
159       return switchType;
160     }
161     return org.apache.myfaces.tobago.model.SwitchType.client;
162   }
163 
164   public void setSwitchType(org.apache.myfaces.tobago.model.SwitchType switchType) {
165     getStateHelper().put(PropertyKeys.switchType, switchType);
166   }
167 
168   /**
169    * @deprecated since 2.0.0
170    */
171   @Deprecated
172   public javax.faces.el.MethodBinding getTabChangeListener() {
173     javax.el.MethodExpression expression = getTabChangeListenerExpression();
174     if (expression instanceof MethodBindingToMethodExpression) {
175       return ((MethodBindingToMethodExpression)expression).getMethodBinding();
176     }
177     if (expression != null) {
178        return new MethodExpressionToMethodBinding(expression);
179     }
180     return null;
181   }
182 
183   /**
184    * @deprecated since 2.0.0
185    */
186   @Deprecated
187   public void setTabChangeListener(javax.faces.el.MethodBinding tabChangeListener) {
188     if (tabChangeListener != null) {
189       setTabChangeListenerExpression(new MethodBindingToMethodExpression(tabChangeListener));
190     } else {
191       setTabChangeListenerExpression(null);
192     }
193   }
194 
195   public javax.el.MethodExpression getTabChangeListenerExpression() {
196     return (javax.el.MethodExpression) getStateHelper().eval(PropertyKeys.tabChangeListener);
197   }
198 
199   public void setTabChangeListenerExpression(javax.el.MethodExpression tabChangeListener) {
200     getStateHelper().put(PropertyKeys.tabChangeListener, tabChangeListener);
201   }
202 
203 
204   public org.apache.myfaces.tobago.context.Markup getMarkup() {
205     Object object = getStateHelper().eval(PropertyKeys.markup);
206     if (object != null) {
207       return Markup.valueOf(object);
208     }
209     return null;
210   }
211 
212   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
213     getStateHelper().put(PropertyKeys.markup, markup);
214   }
215 
216   /**
217   Flag indicating that, if this component is activated by the user,
218    notifications should be delivered to interested listeners and actions
219    immediately (that is, during Apply Request Values phase) rather than
220    waiting until Invoke Application phase.
221   <br>Default: <code>false</code>
222   */
223   public boolean isImmediate() {
224     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.immediate);
225     if (bool != null) {
226       return bool;
227     }
228     return false;
229   }
230 
231   public void setImmediate(boolean immediate) {
232     getStateHelper().put(PropertyKeys.immediate, immediate);
233   }
234 
235   /**
236    * @deprecated since 2.0.0
237    */
238   @Deprecated
239   public javax.faces.el.MethodBinding getAction() {
240     javax.el.MethodExpression expression = getActionExpression();
241     if (expression instanceof MethodBindingToMethodExpression) {
242       return ((MethodBindingToMethodExpression)expression).getMethodBinding();
243     }
244     if (expression != null) {
245        return new MethodExpressionToMethodBinding(expression);
246     }
247     return null;
248   }
249 
250   /**
251    * @deprecated since 2.0.0
252    */
253   @Deprecated
254   public void setAction(javax.faces.el.MethodBinding action) {
255     if (action != null) {
256       setActionExpression(new MethodBindingToMethodExpression(action));
257     } else {
258       setActionExpression(null);
259     }
260   }
261 
262   public javax.el.MethodExpression getActionExpression() {
263     return (javax.el.MethodExpression) getStateHelper().eval(PropertyKeys.action);
264   }
265 
266   public void setActionExpression(javax.el.MethodExpression action) {
267     getStateHelper().put(PropertyKeys.action, action);
268   }
269 
270 
271   /**
272   Sets a CSS class in its parent, if the parent supports it.
273 
274    Which this feature it is possible to put a CSS class name into a component with the &lt;tc:style&gt; tag. Example:
275 
276    <pre>
277    &lt;tc:in&gt;
278      &lt;tc:style customClass="my-emphasized"/&gt;
279    &lt;/tc:in&gt;
280    </pre>
281 
282    One capability is, to used external CSS libs.
283    <br>
284    This feature should not be used imprudent.
285    Because it might be unstable against changes in the renderered HTML code.
286 
287   */
288   public org.apache.myfaces.tobago.renderkit.css.CustomClass getCustomClass() {
289     return (org.apache.myfaces.tobago.renderkit.css.CustomClass) getStateHelper().eval(PropertyKeys.customClass);
290   }
291 
292   public void setCustomClass(org.apache.myfaces.tobago.renderkit.css.CustomClass customClass) {
293     getStateHelper().put(PropertyKeys.customClass, customClass);
294   }
295 
296   /**
297   Flag indicating that the tab navigation bar is rendered.
298   <br>Default: <code>true</code>
299   */
300   public boolean isShowNavigationBar() {
301     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.showNavigationBar);
302     if (bool != null) {
303       return bool;
304     }
305     return true;
306   }
307 
308   public void setShowNavigationBar(boolean showNavigationBar) {
309     getStateHelper().put(PropertyKeys.showNavigationBar, showNavigationBar);
310   }
311 
312   /**
313   For internal use. Used for rendering, if there is a child tag &lt;tc:style&gt;
314 
315   */
316   public org.apache.myfaces.tobago.renderkit.css.Style getStyle() {
317     return (org.apache.myfaces.tobago.renderkit.css.Style) getStateHelper().eval(PropertyKeys.style);
318   }
319 
320   public void setStyle(org.apache.myfaces.tobago.renderkit.css.Style style) {
321     getStateHelper().put(PropertyKeys.style, style);
322   }
323 
324   /**
325   Text value to display as tooltip.
326 
327   */
328   public java.lang.String getTip() {
329     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
330   }
331 
332   public void setTip(java.lang.String tip) {
333     getStateHelper().put(PropertyKeys.tip, tip);
334   }
335 
336   /**
337   <strong>ValueBindingExpression</strong> pointing to a Integer to save the
338    component's selected Tab.
339   <br>Default: <code>0</code>
340   */
341   public java.lang.Integer getSelectedIndex() {
342     Number value  = (Number) getStateHelper().eval(PropertyKeys.selectedIndex);
343     if (value != null) {
344       return value.intValue();
345     }
346     return 0;
347   }
348 
349   public void setSelectedIndex(java.lang.Integer selectedIndex) {
350     getStateHelper().put(PropertyKeys.selectedIndex, selectedIndex);
351   }
352 
353 
354 }