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.AbstractUIStars;
25  import org.apache.myfaces.tobago.renderkit.css.CustomClass;
26  import org.apache.myfaces.tobago.internal.util.ArrayUtils;
27  import org.apache.myfaces.tobago.internal.util.StringUtils;
28  import org.apache.myfaces.tobago.internal.util.Deprecation;
29  import org.apache.myfaces.tobago.component.Tags;
30  import javax.annotation.Generated;
31  import javax.el.ELException;
32  import javax.faces.FacesException;
33  import java.util.Arrays;
34  import java.util.ArrayList;
35  import java.util.Collection;
36  import java.util.List;
37  import javax.el.MethodExpression;
38  import javax.el.ValueExpression;
39  
40  /**
41   Renders a star rating component.
42    * UIComponent class, generated from template {@code component.stg} with class
43    * {@link org.apache.myfaces.tobago.internal.taglib.component.StarsTagDeclaration}.
44   */
45  @Generated("component.stg")
46  public class UIStars
47      extends AbstractUIStars  {
48  
49    public static final String COMPONENT_TYPE = Tags.stars.componentType();
50  
51    public static final String COMPONENT_FAMILY = "javax.faces.Input";
52  
53    private static final Collection<String> EVENT_NAMES = Arrays.asList("change", "click", "dblclick");
54  
55    @Override
56    public Collection<String> getEventNames() {
57      return EVENT_NAMES;
58    }
59  
60    @Override
61    public String getDefaultEventName() {
62      return "change";
63    }
64  
65  
66    enum PropertyKeys {
67      markup,
68      max,
69      labelLayout,
70      focus,
71      tabIndex,
72      label,
73      help,
74      readonly,
75      accessKey,
76      customClass,
77      disabled,
78      tip,
79      placeholder,
80    }
81  
82    public String getFamily() {
83      return COMPONENT_FAMILY;
84    }
85  
86  
87    public org.apache.myfaces.tobago.context.Markup getMarkup() {
88      Object object = getStateHelper().eval(PropertyKeys.markup);
89      if (object != null) {
90        return Markup.valueOf(object);
91      }
92      return null;
93    }
94  
95    public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
96      getStateHelper().put(PropertyKeys.markup, markup);
97    }
98  
99    /**
100   The maximum value must be &gt; '0'. Default is '5'.
101    To split stars, set a higher maximum value.
102    E.g. set '10' for half stars, set '20' for quarter stars.
103 
104   */
105   public java.lang.Integer getMax() {
106     Number value  = (Number) getStateHelper().eval(PropertyKeys.max);
107     if (value != null) {
108       return value.intValue();
109     }
110     return null;
111   }
112 
113   public void setMax(java.lang.Integer max) {
114     getStateHelper().put(PropertyKeys.max, max);
115   }
116 
117   /**
118   Defines the position of the label relative to the field.
119    The default is flexLeft, if the label is set, or none, if the label isn't set.
120    Set to 'skip' to avoid surrounding label container.
121    Hint for tc:out: set also compact=true to render only text (without html tags).
122 
123   */
124   public org.apache.myfaces.tobago.component.LabelLayout getLabelLayout() {
125     org.apache.myfaces.tobago.component.LabelLayout labelLayout = (org.apache.myfaces.tobago.component.LabelLayout) getStateHelper().eval(PropertyKeys.labelLayout);
126     if (labelLayout != null) {
127       return labelLayout;
128     }
129     return getLabel() != null ? org.apache.myfaces.tobago.component.LabelLayout.flexLeft : org.apache.myfaces.tobago.component.LabelLayout.none;
130   }
131 
132   public void setLabelLayout(org.apache.myfaces.tobago.component.LabelLayout labelLayout) {
133     getStateHelper().put(PropertyKeys.labelLayout, labelLayout);
134   }
135 
136   /**
137   Flag indicating this component should receive the focus.
138   <br>Default: <code>false</code>
139   */
140   public boolean isFocus() {
141     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.focus);
142     if (bool != null) {
143       return bool;
144     }
145     return false;
146   }
147 
148   public void setFocus(boolean focus) {
149     getStateHelper().put(PropertyKeys.focus, focus);
150   }
151 
152   /**
153   Controls the navigation of the focus through the
154    input controls on a page with the Tab-Key.
155    The navigation starts from the element with
156    the lowest tabIndex value to the element with the highest value.
157    Elements that have identical tabIndex values should be navigated
158    in the order they appear in the character stream
159    Elements that are disabled or with a negative tabIndex
160    do not participate in the tabbing order.
161 
162   */
163   public java.lang.Integer getTabIndex() {
164     Number value  = (Number) getStateHelper().eval(PropertyKeys.tabIndex);
165     if (value != null) {
166       return value.intValue();
167     }
168     return null;
169   }
170 
171   public void setTabIndex(java.lang.Integer tabIndex) {
172     getStateHelper().put(PropertyKeys.tabIndex, tabIndex);
173   }
174 
175   /**
176   A localized user presentable label for this component.
177 
178   */
179   public java.lang.String getLabel() {
180     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
181   }
182 
183   public void setLabel(java.lang.String label) {
184     getStateHelper().put(PropertyKeys.label, label);
185   }
186 
187   /**
188   Text value to display as a help.
189 
190   */
191   public java.lang.String getHelp() {
192     return (java.lang.String) getStateHelper().eval(PropertyKeys.help);
193   }
194 
195   public void setHelp(java.lang.String help) {
196     getStateHelper().put(PropertyKeys.help, help);
197   }
198 
199   /**
200   Flag indicating that this component will prohibit changes by the user.
201   <br>Default: <code>false</code>
202   */
203   public boolean isReadonly() {
204     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.readonly);
205     if (bool != null) {
206       return bool;
207     }
208     return false;
209   }
210 
211   public void setReadonly(boolean readonly) {
212     getStateHelper().put(PropertyKeys.readonly, readonly);
213   }
214 
215   /**
216   The access key of this control.
217 
218   */
219   public java.lang.Character getAccessKey() {
220     return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
221   }
222 
223   public void setAccessKey(java.lang.Character accessKey) {
224     getStateHelper().put(PropertyKeys.accessKey, accessKey);
225   }
226 
227   /**
228   Sets a CSS class in its parent, if the parent supports it.
229 
230    Which this feature it is possible to put a CSS class name into a component with the &lt;tc:style&gt; tag. Example:
231 
232    <pre>
233    &lt;tc:in&gt;
234      &lt;tc:style customClass="my-emphasized"/&gt;
235    &lt;/tc:in&gt;
236    </pre>
237 
238    One capability is, to used external CSS libs.
239    <br>
240    This feature should not be used imprudent.
241    Because it might be unstable against changes in the renderered HTML code.
242 
243   */
244   public org.apache.myfaces.tobago.renderkit.css.CustomClass getCustomClass() {
245     return (org.apache.myfaces.tobago.renderkit.css.CustomClass) getStateHelper().eval(PropertyKeys.customClass);
246   }
247 
248   public void setCustomClass(org.apache.myfaces.tobago.renderkit.css.CustomClass customClass) {
249     getStateHelper().put(PropertyKeys.customClass, customClass);
250   }
251 
252   /**
253   Flag indicating that this element is disabled.
254   <br>Default: <code>false</code>
255   */
256   public boolean isDisabled() {
257     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
258     if (bool != null) {
259       return bool;
260     }
261     return false;
262   }
263 
264   public void setDisabled(boolean disabled) {
265     getStateHelper().put(PropertyKeys.disabled, disabled);
266   }
267 
268   /**
269   Text value to display as tooltip.
270 
271   */
272   public java.lang.String getTip() {
273     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
274   }
275 
276   public void setTip(java.lang.String tip) {
277     getStateHelper().put(PropertyKeys.tip, tip);
278   }
279 
280   /**
281   The placeholder value is displayed if no star is set by the user.
282    Value must be between '0' and '5'.
283    The placeholder can show values which are not selectable by the user.
284    E.g. if only full stars are available for the user, the placeholder can show a 4.6 star rating.
285 
286   */
287   public java.lang.Double getPlaceholder() {
288     return (java.lang.Double) getStateHelper().eval(PropertyKeys.placeholder);
289   }
290 
291   public void setPlaceholder(java.lang.Double placeholder) {
292     getStateHelper().put(PropertyKeys.placeholder, placeholder);
293   }
294 
295 
296   @Override
297   public void restoreState(FacesContext context, Object state) {
298     // FIXME HACK for mojarra SystemEventListener state restoring bug
299     pushComponentToEL(context, this);
300     super.restoreState(context, state);
301     popComponentFromEL(context);
302   }
303 
304 }