1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts.faces.component;
23
24
25 import javax.faces.component.UIOutput;
26 import javax.faces.context.FacesContext;
27 import javax.faces.el.ValueBinding;
28
29
30
31
32
33
34
35 public class MessageComponent extends UIOutput {
36
37
38
39
40
41
42
43
44 public MessageComponent() {
45
46 super();
47 setRendererType("org.apache.struts.faces.Message");
48
49 }
50
51
52
53
54
55
56
57
58 private String bundle = null;
59
60
61
62
63
64 private boolean filter = true;
65 private boolean filterSet = false;
66
67
68
69
70
71 private String key = null;
72
73
74
75
76
77 private String style = null;
78
79
80
81
82
83 private String styleClass = null;
84
85
86
87
88
89
90
91
92 public String getBundle() {
93
94 ValueBinding vb = getValueBinding("bundle");
95 if (vb != null) {
96 return (String) vb.getValue(getFacesContext());
97 } else {
98 return bundle;
99 }
100
101 }
102
103
104
105
106
107
108
109 public void setBundle(String bundle) {
110
111 this.bundle = bundle;
112
113 }
114
115
116
117
118
119 public String getFamily() {
120
121 return "org.apache.struts.faces.Message";
122
123 }
124
125
126
127
128
129 public boolean isFilter() {
130
131 if (filterSet) {
132 return filter;
133 }
134 ValueBinding vb = getValueBinding("filter");
135 if (vb != null) {
136 Boolean value = (Boolean) vb.getValue(getFacesContext());
137 if (null == value) {
138 return filter;
139 }
140 return value.booleanValue();
141 } else {
142 return filter;
143 }
144
145 }
146
147
148
149
150
151
152
153 public void setFilter(boolean filter) {
154
155 this.filter = filter;
156 this.filterSet = true;
157
158 }
159
160
161
162
163
164 public String getKey() {
165
166 ValueBinding vb = getValueBinding("key");
167 if (vb != null) {
168 return (String) vb.getValue(getFacesContext());
169 } else {
170 return key;
171 }
172
173 }
174
175
176
177
178
179
180
181 public void setKey(String key) {
182
183 this.key = key;
184
185 }
186
187
188
189
190
191 public String getStyle() {
192
193 ValueBinding vb = getValueBinding("style");
194 if (vb != null) {
195 return (String) vb.getValue(getFacesContext());
196 } else {
197 return style;
198 }
199
200 }
201
202
203
204
205
206
207
208 public void setStyle(String style) {
209
210 this.style = style;
211
212 }
213
214
215
216
217
218 public String getStyleClass() {
219
220 ValueBinding vb = getValueBinding("styleClass");
221 if (vb != null) {
222 return (String) vb.getValue(getFacesContext());
223 } else {
224 return styleClass;
225 }
226
227 }
228
229
230
231
232
233
234
235 public void setStyleClass(String styleClass) {
236
237 this.styleClass = styleClass;
238
239 }
240
241
242
243
244
245
246
247
248
249
250
251 public void restoreState(FacesContext context, Object state) {
252
253 Object values[] = (Object[]) state;
254 super.restoreState(context, values[0]);
255 bundle = (String) values[1];
256 filter = ((Boolean) values[2]).booleanValue();
257 filterSet = ((Boolean) values[3]).booleanValue();
258 key = (String) values[4];
259 style = (String) values[5];
260 styleClass = (String) values[6];
261
262 }
263
264
265
266
267
268
269
270 public Object saveState(FacesContext context) {
271
272 Object values[] = new Object[7];
273 values[0] = super.saveState(context);
274 values[1] = bundle;
275 values[2] = filter ? Boolean.TRUE : Boolean.FALSE;
276 values[3] = filterSet ? Boolean.TRUE : Boolean.FALSE;
277 values[4] = key;
278 values[5] = style;
279 values[6] = styleClass;
280 return values;
281
282 }
283
284
285 }