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.commons.lang.ArrayUtils;
28  import org.apache.commons.lang.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      accessKey,
62      markup,
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      currentHeight,
81      preferredHeight,
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    /**
100   Deprecated! Has not longer any function.
101 
102   @deprecated*/
103   @Deprecated
104   public java.lang.Character getAccessKey() {
105       Deprecation.LOG.error("The attribute 'accessKey' of 'UIFile' is deprecated. "
106           + "Please refer the documentation for further information.");
107     return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
108   }
109 
110   @Deprecated
111   public void setAccessKey(java.lang.Character accessKey) {
112     getStateHelper().put(PropertyKeys.accessKey, accessKey);
113   }
114 
115   public org.apache.myfaces.tobago.context.Markup getMarkup() {
116     Object object = getStateHelper().eval(PropertyKeys.markup);
117     if (object != null) {
118       return Markup.valueOf(object);
119     }
120     return null;
121   }
122 
123   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
124     getStateHelper().put(PropertyKeys.markup, markup);
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 ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this);
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       Deprecation.LOG.error("The attribute 'labelWithAccessKey' of 'UIFile' is deprecated. "
148           + "Please refer the documentation for further information.");
149     return (java.lang.String) getStateHelper().eval(PropertyKeys.labelWithAccessKey);
150   }
151 
152   @Deprecated
153   public void setLabelWithAccessKey(java.lang.String labelWithAccessKey) {
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 ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumHeight(getFacesContext(), this);
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 ((LayoutComponentRenderer) getRenderer(getFacesContext())).getHeight(getFacesContext(), this);
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 ((LayoutComponentRenderer)getRenderer(getFacesContext())).getMinimumWidth(getFacesContext(), this);
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 ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumHeight(getFacesContext(), this);
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 ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this);
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 ((LayoutComponentRenderer) getRenderer(getFacesContext())).getWidth(getFacesContext(), this);
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 ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this);
366   }
367 
368   public void setMarginRight(org.apache.myfaces.tobago.layout.Measure marginRight) {
369     getStateHelper().put(PropertyKeys.marginRight, marginRight);
370   }
371 
372   /**
373   This value will usually be set by the layout manager. It holds the current height computed by the layout manager.
374 
375   */
376   public org.apache.myfaces.tobago.layout.Measure getCurrentHeight() {
377     Object object = getStateHelper().eval(PropertyKeys.currentHeight);
378     if (object != null) {
379        return Measure.valueOf(object);
380     }
381     return getHeight();
382   }
383 
384   public void setCurrentHeight(org.apache.myfaces.tobago.layout.Measure currentHeight) {
385     getStateHelper().put(PropertyKeys.currentHeight, currentHeight);
386   }
387 
388   public org.apache.myfaces.tobago.layout.Measure getPreferredHeight() {
389     Object object = getStateHelper().eval(PropertyKeys.preferredHeight);
390     if (object != null) {
391        return Measure.valueOf(object);
392     }
393     return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredHeight(getFacesContext(), this);
394   }
395 
396   public void setPreferredHeight(org.apache.myfaces.tobago.layout.Measure preferredHeight) {
397     getStateHelper().put(PropertyKeys.preferredHeight, preferredHeight);
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 ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this);
431   }
432 
433   public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
434     getStateHelper().put(PropertyKeys.maximumWidth, maximumWidth);
435   }
436 
437   /**
438   Clientside script function to add to this component's onchange handler.
439 
440   */
441   public java.lang.String getOnchange() {
442     return (java.lang.String) getStateHelper().eval(PropertyKeys.onchange);
443   }
444 
445   public void setOnchange(java.lang.String onchange) {
446     getStateHelper().put(PropertyKeys.onchange, onchange);
447   }
448 
449   public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
450     Object object = getStateHelper().eval(PropertyKeys.preferredWidth);
451     if (object != null) {
452        return Measure.valueOf(object);
453     }
454     return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this);
455   }
456 
457   public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
458     getStateHelper().put(PropertyKeys.preferredWidth, preferredWidth);
459   }
460 
461   public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
462     Object object = getStateHelper().eval(PropertyKeys.marginBottom);
463     if (object != null) {
464        return Measure.valueOf(object);
465     }
466     return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this);
467   }
468 
469   public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
470     getStateHelper().put(PropertyKeys.marginBottom, marginBottom);
471   }
472 
473   /**
474   This attribute is for internal use only.
475 
476   */
477   public java.lang.Integer getVerticalIndex() {
478     Number value  = (Number) getStateHelper().eval(PropertyKeys.verticalIndex);
479     if (value != null) {
480       return value.intValue();
481     }
482     return null;
483   }
484 
485   public void setVerticalIndex(java.lang.Integer verticalIndex) {
486     getStateHelper().put(PropertyKeys.verticalIndex, verticalIndex);
487   }
488 
489   public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
490     if (currentMarkup != null) {
491       return currentMarkup;
492     }
493     return null;
494   }
495 
496   public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
497     this.currentMarkup = currentMarkup;
498   }
499 
500   /**
501   This attribute is for internal use only.
502 
503   */
504   public java.lang.Integer getHorizontalIndex() {
505     Number value  = (Number) getStateHelper().eval(PropertyKeys.horizontalIndex);
506     if (value != null) {
507       return value.intValue();
508     }
509     return null;
510   }
511 
512   public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
513     getStateHelper().put(PropertyKeys.horizontalIndex, horizontalIndex);
514   }
515 
516   /**
517   Flag indicating that this component will prohibit changes by the user.
518   <br />Default: <code>false</code>
519   */
520   public boolean isReadonly() {
521     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.readonly);
522     if (bool != null) {
523       return bool;
524     }
525     return false;
526   }
527 
528   public void setReadonly(boolean readonly) {
529     getStateHelper().put(PropertyKeys.readonly, readonly);
530   }
531 
532   /**
533   Flag indicating that this element is disabled.
534   <br />Default: <code>false</code>
535   */
536   public boolean isDisabled() {
537     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
538     if (bool != null) {
539       return bool;
540     }
541     return false;
542   }
543 
544   public void setDisabled(boolean disabled) {
545     getStateHelper().put(PropertyKeys.disabled, disabled);
546   }
547 
548   public Object saveState(FacesContext context) {
549     currentMarkup = null;
550     return super.saveState(context);
551   }
552 
553 
554 }