1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package javax.faces.component; |
20 | |
|
21 | |
import javax.el.ValueExpression; |
22 | |
import javax.faces.context.FacesContext; |
23 | |
import javax.faces.convert.Converter; |
24 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent; |
25 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
@JSFComponent(defaultRendererType = "javax.faces.Text") |
31 | |
public class UIOutput extends UIComponentBase implements ValueHolder |
32 | |
{ |
33 | |
public static final String COMPONENT_TYPE = "javax.faces.Output"; |
34 | |
public static final String COMPONENT_FAMILY = "javax.faces.Output"; |
35 | |
|
36 | |
private Object _value; |
37 | |
private Converter _converter; |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
public UIOutput() |
43 | 0 | { |
44 | 0 | setRendererType("javax.faces.Text"); |
45 | 0 | } |
46 | |
|
47 | |
@Override |
48 | |
public String getFamily() |
49 | |
{ |
50 | 0 | return COMPONENT_FAMILY; |
51 | |
} |
52 | |
|
53 | |
public Object getLocalValue() |
54 | |
{ |
55 | 0 | return _value; |
56 | |
} |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
@JSFProperty |
64 | |
public Object getValue() |
65 | |
{ |
66 | 0 | if (_value != null) |
67 | |
{ |
68 | 0 | return _value; |
69 | |
} |
70 | 0 | ValueExpression expression = getValueExpression("value"); |
71 | 0 | if (expression != null) |
72 | |
{ |
73 | 0 | return expression.getValue(getFacesContext().getELContext()); |
74 | |
} |
75 | 0 | return null; |
76 | |
} |
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
public void setValue(Object value) |
82 | |
{ |
83 | 0 | this._value = value; |
84 | 0 | } |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
@JSFProperty(stateHolder=true) |
96 | |
public Converter getConverter() |
97 | |
{ |
98 | 0 | if (_converter != null) |
99 | |
{ |
100 | 0 | return _converter; |
101 | |
} |
102 | 0 | ValueExpression expression = getValueExpression("converter"); |
103 | 0 | if (expression != null) |
104 | |
{ |
105 | 0 | return (Converter) expression.getValue(getFacesContext().getELContext()); |
106 | |
} |
107 | 0 | return null; |
108 | |
} |
109 | |
|
110 | |
public void setConverter(Converter converter) |
111 | |
{ |
112 | 0 | this._converter = converter; |
113 | 0 | } |
114 | |
|
115 | |
@Override |
116 | |
public Object saveState(FacesContext facesContext) |
117 | |
{ |
118 | 0 | Object[] values = new Object[3]; |
119 | 0 | values[0] = super.saveState(facesContext); |
120 | 0 | values[1] = _value; |
121 | 0 | values[2] = saveAttachedState(facesContext, _converter); |
122 | |
|
123 | 0 | return values; |
124 | |
} |
125 | |
|
126 | |
@Override |
127 | |
public void restoreState(FacesContext facesContext, Object state) |
128 | |
{ |
129 | 0 | Object[] values = (Object[]) state; |
130 | 0 | super.restoreState(facesContext, values[0]); |
131 | 0 | _value = values[1]; |
132 | 0 | _converter = (Converter) restoreAttachedState(facesContext, values[2]); |
133 | 0 | } |
134 | |
} |