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