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.AbstractUIFile;
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 file input field.
42    You need to define an org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter in your web.xml or
43    add the tobago-fileupload.jar to your project.
44    The tobago-fileupload.jar contains a FacesContextFactory that wraps the
45    multipart-formdata request inside the facesContext.
46    <p />
47    For content constraints please use <a href="validateFileItem.html">tc:validateFileItem</a>.
48    * UIComponent class, generated from template {@code component2.0.stg} with class
49    * {@link org.apache.myfaces.tobago.internal.taglib.component.FileTagDeclaration}.
50   */
51  public class UIFile
52      extends AbstractUIFile implements SupportsMarkup {
53  
54    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.File";
55  
56    public static final String COMPONENT_FAMILY = "javax.faces.Input";
57  
58    private org.apache.myfaces.tobago.context.Markup currentMarkup;
59  
60    enum PropertyKeys {
61      markup,
62      marginLeft,
63      tabIndex,
64      minimumHeight,
65      tip,
66      height,
67      minimumWidth,
68      rowSpan,
69      left,
70      focus,
71      columnSpan,
72      top,
73      maximumHeight,
74      currentWidth,
75      marginTop,
76      width,
77      marginRight,
78      currentHeight,
79      preferredHeight,
80      display,
81      label,
82      maximumWidth,
83      onchange,
84      preferredWidth,
85      marginBottom,
86      verticalIndex,
87      horizontalIndex,
88      readonly,
89      disabled,
90    }
91  
92    public String getFamily() {
93      return COMPONENT_FAMILY;
94    }
95  
96  
97    public org.apache.myfaces.tobago.context.Markup getMarkup() {
98      Object object = getStateHelper().eval(PropertyKeys.markup);
99      if (object != null) {
100       return Markup.valueOf(object);
101     }
102     return null;
103   }
104 
105   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
106     getStateHelper().put(PropertyKeys.markup, markup);
107   }
108 
109   public org.apache.myfaces.tobago.layout.Measure getMarginLeft() {
110     Object object = getStateHelper().eval(PropertyKeys.marginLeft);
111     if (object != null) {
112        return Measure.valueOf(object);
113     }
114     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this) : Measure.ZERO;
115   }
116 
117   public void setMarginLeft(org.apache.myfaces.tobago.layout.Measure marginLeft) {
118     getStateHelper().put(PropertyKeys.marginLeft, marginLeft);
119   }
120 
121   /**
122   Controls the navigation of the focus through the
123    input controls on a page with the Tab-Key.
124    The navigation starts from the element with
125    the lowest tabIndex value to the element with the highest value.
126    Elements that have identical tabIndex values should be navigated
127    in the order they appear in the character stream
128    Elements that are disabled or with a negative tabIndex
129    do not participate in the tabbing order.
130 
131   */
132   public java.lang.Integer getTabIndex() {
133     Number value  = (Number) getStateHelper().eval(PropertyKeys.tabIndex);
134     if (value != null) {
135       return value.intValue();
136     }
137     return null;
138   }
139 
140   public void setTabIndex(java.lang.Integer tabIndex) {
141     getStateHelper().put(PropertyKeys.tabIndex, tabIndex);
142   }
143 
144   public org.apache.myfaces.tobago.layout.Measure getMinimumHeight() {
145     Object object = getStateHelper().eval(PropertyKeys.minimumHeight);
146     if (object != null) {
147        return Measure.valueOf(object);
148     }
149     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumHeight(getFacesContext(), this) : Measure.ZERO;
150   }
151 
152   public void setMinimumHeight(org.apache.myfaces.tobago.layout.Measure minimumHeight) {
153     getStateHelper().put(PropertyKeys.minimumHeight, minimumHeight);
154   }
155 
156   /**
157   Text value to display as tooltip.
158 
159   */
160   public java.lang.String getTip() {
161     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
162   }
163 
164   public void setTip(java.lang.String tip) {
165     getStateHelper().put(PropertyKeys.tip, tip);
166   }
167 
168   /**
169   This value will usually be set by the layout manager.
170 
171   */
172   public org.apache.myfaces.tobago.layout.Measure getHeight() {
173     Object object = getStateHelper().eval(PropertyKeys.height);
174     if (object != null) {
175        return Measure.valueOf(object);
176     }
177     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getHeight(getFacesContext(), this) : Measure.ZERO;
178   }
179 
180   public void setHeight(org.apache.myfaces.tobago.layout.Measure height) {
181     getStateHelper().put(PropertyKeys.height, height);
182   }
183 
184   public org.apache.myfaces.tobago.layout.Measure getMinimumWidth() {
185     Object object = getStateHelper().eval(PropertyKeys.minimumWidth);
186     if (object != null) {
187        return Measure.valueOf(object);
188     }
189     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumWidth(getFacesContext(), this) : Measure.ZERO;
190   }
191 
192   public void setMinimumWidth(org.apache.myfaces.tobago.layout.Measure minimumWidth) {
193     getStateHelper().put(PropertyKeys.minimumWidth, minimumWidth);
194   }
195 
196   public java.lang.Integer getRowSpan() {
197     Number value  = (Number) getStateHelper().eval(PropertyKeys.rowSpan);
198     if (value != null) {
199       return value.intValue();
200     }
201     return 1;
202   }
203 
204   public void setRowSpan(java.lang.Integer rowSpan) {
205     getStateHelper().put(PropertyKeys.rowSpan, rowSpan);
206   }
207 
208   /**
209   This value will usually be set by the layout manager.
210 
211   */
212   public org.apache.myfaces.tobago.layout.Measure getLeft() {
213     Object object = getStateHelper().eval(PropertyKeys.left);
214     if (object != null) {
215        return Measure.valueOf(object);
216     }
217     return null;
218   }
219 
220   public void setLeft(org.apache.myfaces.tobago.layout.Measure left) {
221     getStateHelper().put(PropertyKeys.left, left);
222   }
223 
224   /**
225   Flag indicating this component should receive the focus.
226   <br />Default: <code>false</code>
227   */
228   public boolean isFocus() {
229     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.focus);
230     if (bool != null) {
231       return bool;
232     }
233     return false;
234   }
235 
236   public void setFocus(boolean focus) {
237     getStateHelper().put(PropertyKeys.focus, focus);
238   }
239 
240   public java.lang.Integer getColumnSpan() {
241     Number value  = (Number) getStateHelper().eval(PropertyKeys.columnSpan);
242     if (value != null) {
243       return value.intValue();
244     }
245     return 1;
246   }
247 
248   public void setColumnSpan(java.lang.Integer columnSpan) {
249     getStateHelper().put(PropertyKeys.columnSpan, columnSpan);
250   }
251 
252   /**
253   This value will usually be set by the layout manager.
254 
255   */
256   public org.apache.myfaces.tobago.layout.Measure getTop() {
257     Object object = getStateHelper().eval(PropertyKeys.top);
258     if (object != null) {
259        return Measure.valueOf(object);
260     }
261     return null;
262   }
263 
264   public void setTop(org.apache.myfaces.tobago.layout.Measure top) {
265     getStateHelper().put(PropertyKeys.top, top);
266   }
267 
268   public org.apache.myfaces.tobago.layout.Measure getMaximumHeight() {
269     Object object = getStateHelper().eval(PropertyKeys.maximumHeight);
270     if (object != null) {
271        return Measure.valueOf(object);
272     }
273     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumHeight(getFacesContext(), this) : Measure.ZERO;
274   }
275 
276   public void setMaximumHeight(org.apache.myfaces.tobago.layout.Measure maximumHeight) {
277     getStateHelper().put(PropertyKeys.maximumHeight, maximumHeight);
278   }
279 
280   /**
281   This value will usually be set by the layout manager. It holds the current width computed by the layout manager.
282 
283   */
284   public org.apache.myfaces.tobago.layout.Measure getCurrentWidth() {
285     Object object = getStateHelper().eval(PropertyKeys.currentWidth);
286     if (object != null) {
287        return Measure.valueOf(object);
288     }
289     return getWidth();
290   }
291 
292   public void setCurrentWidth(org.apache.myfaces.tobago.layout.Measure currentWidth) {
293     getStateHelper().put(PropertyKeys.currentWidth, currentWidth);
294   }
295 
296   public org.apache.myfaces.tobago.layout.Measure getMarginTop() {
297     Object object = getStateHelper().eval(PropertyKeys.marginTop);
298     if (object != null) {
299        return Measure.valueOf(object);
300     }
301     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this) : Measure.ZERO;
302   }
303 
304   public void setMarginTop(org.apache.myfaces.tobago.layout.Measure marginTop) {
305     getStateHelper().put(PropertyKeys.marginTop, marginTop);
306   }
307 
308   /**
309   This value will usually be set by the layout manager.
310 
311   */
312   public org.apache.myfaces.tobago.layout.Measure getWidth() {
313     Object object = getStateHelper().eval(PropertyKeys.width);
314     if (object != null) {
315        return Measure.valueOf(object);
316     }
317     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getWidth(getFacesContext(), this) : Measure.ZERO;
318   }
319 
320   public void setWidth(org.apache.myfaces.tobago.layout.Measure width) {
321     getStateHelper().put(PropertyKeys.width, width);
322   }
323 
324   public org.apache.myfaces.tobago.layout.Measure getMarginRight() {
325     Object object = getStateHelper().eval(PropertyKeys.marginRight);
326     if (object != null) {
327        return Measure.valueOf(object);
328     }
329     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this) : Measure.ZERO;
330   }
331 
332   public void setMarginRight(org.apache.myfaces.tobago.layout.Measure marginRight) {
333     getStateHelper().put(PropertyKeys.marginRight, marginRight);
334   }
335 
336   /**
337   This value will usually be set by the layout manager. It holds the current height computed by the layout manager.
338 
339   */
340   public org.apache.myfaces.tobago.layout.Measure getCurrentHeight() {
341     Object object = getStateHelper().eval(PropertyKeys.currentHeight);
342     if (object != null) {
343        return Measure.valueOf(object);
344     }
345     return getHeight();
346   }
347 
348   public void setCurrentHeight(org.apache.myfaces.tobago.layout.Measure currentHeight) {
349     getStateHelper().put(PropertyKeys.currentHeight, currentHeight);
350   }
351 
352   public org.apache.myfaces.tobago.layout.Measure getPreferredHeight() {
353     Object object = getStateHelper().eval(PropertyKeys.preferredHeight);
354     if (object != null) {
355        return Measure.valueOf(object);
356     }
357     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredHeight(getFacesContext(), this) : Measure.ZERO;
358   }
359 
360   public void setPreferredHeight(org.apache.myfaces.tobago.layout.Measure preferredHeight) {
361     getStateHelper().put(PropertyKeys.preferredHeight, preferredHeight);
362   }
363 
364   /**
365   This attribute is for internal use only.
366 
367   */
368   public org.apache.myfaces.tobago.layout.Display getDisplay() {
369     return (org.apache.myfaces.tobago.layout.Display) getStateHelper().eval(PropertyKeys.display);
370   }
371 
372   public void setDisplay(org.apache.myfaces.tobago.layout.Display display) {
373     getStateHelper().put(PropertyKeys.display, display);
374   }
375 
376   /**
377   Text value to display as label.
378    If text contains an underscore the next character is used as accesskey (if configured so and possible).
379 
380   */
381   public java.lang.String getLabel() {
382     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
383   }
384 
385   public void setLabel(java.lang.String label) {
386     getStateHelper().put(PropertyKeys.label, label);
387   }
388 
389   public org.apache.myfaces.tobago.layout.Measure getMaximumWidth() {
390     Object object = getStateHelper().eval(PropertyKeys.maximumWidth);
391     if (object != null) {
392        return Measure.valueOf(object);
393     }
394     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this) : Measure.ZERO;
395   }
396 
397   public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
398     getStateHelper().put(PropertyKeys.maximumWidth, maximumWidth);
399   }
400 
401   /**
402   Client side script function to add to this component's onchange handler.
403 
404   @deprecated*/
405   @Deprecated
406   public java.lang.String getOnchange() {
407     return (java.lang.String) getStateHelper().eval(PropertyKeys.onchange);
408   }
409 
410   @Deprecated
411   public void setOnchange(java.lang.String onchange) {
412       Deprecation.LOG.error("The attribute 'onchange' of 'UIFile' is deprecated. "
413           + "Please refer the documentation for further information.");
414     getStateHelper().put(PropertyKeys.onchange, onchange);
415   }
416 
417   public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
418     Object object = getStateHelper().eval(PropertyKeys.preferredWidth);
419     if (object != null) {
420        return Measure.valueOf(object);
421     }
422     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this) : Measure.ZERO;
423   }
424 
425   public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
426     getStateHelper().put(PropertyKeys.preferredWidth, preferredWidth);
427   }
428 
429   public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
430     Object object = getStateHelper().eval(PropertyKeys.marginBottom);
431     if (object != null) {
432        return Measure.valueOf(object);
433     }
434     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this) : Measure.ZERO;
435   }
436 
437   public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
438     getStateHelper().put(PropertyKeys.marginBottom, marginBottom);
439   }
440 
441   /**
442   This attribute is for internal use only.
443 
444   */
445   public java.lang.Integer getVerticalIndex() {
446     Number value  = (Number) getStateHelper().eval(PropertyKeys.verticalIndex);
447     if (value != null) {
448       return value.intValue();
449     }
450     return null;
451   }
452 
453   public void setVerticalIndex(java.lang.Integer verticalIndex) {
454     getStateHelper().put(PropertyKeys.verticalIndex, verticalIndex);
455   }
456 
457   public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
458     if (currentMarkup != null) {
459       return currentMarkup;
460     }
461     return null;
462   }
463 
464   public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
465     this.currentMarkup = currentMarkup;
466   }
467 
468   /**
469   This attribute is for internal use only.
470 
471   */
472   public java.lang.Integer getHorizontalIndex() {
473     Number value  = (Number) getStateHelper().eval(PropertyKeys.horizontalIndex);
474     if (value != null) {
475       return value.intValue();
476     }
477     return null;
478   }
479 
480   public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
481     getStateHelper().put(PropertyKeys.horizontalIndex, horizontalIndex);
482   }
483 
484   /**
485   Flag indicating that this component will prohibit changes by the user.
486   <br />Default: <code>false</code>
487   */
488   public boolean isReadonly() {
489     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.readonly);
490     if (bool != null) {
491       return bool;
492     }
493     return false;
494   }
495 
496   public void setReadonly(boolean readonly) {
497     getStateHelper().put(PropertyKeys.readonly, readonly);
498   }
499 
500   /**
501   Flag indicating that this element is disabled.
502   <br />Default: <code>false</code>
503   */
504   public boolean isDisabled() {
505     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
506     if (bool != null) {
507       return bool;
508     }
509     return false;
510   }
511 
512   public void setDisabled(boolean disabled) {
513     getStateHelper().put(PropertyKeys.disabled, disabled);
514   }
515 
516   public Object saveState(FacesContext context) {
517     currentMarkup = null;
518     return super.saveState(context);
519   }
520 
521 }