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