1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.element;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
21 import org.kuali.rice.krad.datadictionary.parse.BeanTags;
22 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
23 import org.kuali.rice.krad.datadictionary.validator.Validator;
24 import org.kuali.rice.krad.uif.component.Component;
25 import org.kuali.rice.krad.uif.util.ComponentFactory;
26 import org.kuali.rice.krad.uif.util.LifecycleElement;
27
28
29
30
31
32
33 @BeanTag(name = "image", parent = "Uif-Image")
34 public class Image extends ContentElementBase {
35 private static final long serialVersionUID = -3911849875276940507L;
36
37 private String source;
38 private String altText;
39 private String height;
40 private String width;
41
42 private boolean captionHeaderPlacementAboveImage;
43
44 private String captionHeaderText;
45 private Header captionHeader;
46
47 private String cutlineText;
48 private Message cutlineMessage;
49
50 public Image() {
51 super();
52
53 altText = "";
54 }
55
56
57
58
59
60
61
62
63
64
65 @Override
66 public void performInitialization(Object model) {
67 super.performInitialization(model);
68
69 if ((StringUtils.isNotBlank(captionHeaderText) || (getPropertyExpression("captionHeaderText") != null)) && (
70 captionHeader == null)) {
71 captionHeader = ComponentFactory.getImageCaptionHeader();
72 }
73
74 if ((StringUtils.isNotBlank(cutlineText) || (getPropertyExpression("cutlineText") != null)) && (cutlineMessage
75 == null)) {
76 cutlineMessage = ComponentFactory.getImageCutlineMessage();
77 }
78 }
79
80
81
82
83
84
85
86
87
88
89
90 @Override
91 public void performApplyModel(Object model, LifecycleElement parent) {
92 super.performApplyModel(model, parent);
93
94 if (StringUtils.isNotBlank(captionHeaderText)) {
95 captionHeader.setHeaderText(captionHeaderText);
96 }
97
98 if (StringUtils.isNotBlank(cutlineText)) {
99 cutlineMessage.setMessageText(cutlineText);
100 }
101 }
102
103
104
105
106
107
108 @BeanTagAttribute
109 public String getSource() {
110 return this.source;
111 }
112
113
114
115
116
117
118 public void setSource(String source) {
119 this.source = source;
120 }
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 @BeanTagAttribute
141 public String getAltText() {
142 return this.altText;
143 }
144
145
146
147
148
149
150 public void setAltText(String altText) {
151 this.altText = altText;
152 }
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167 @BeanTagAttribute
168 public String getHeight() {
169 return this.height;
170 }
171
172
173
174
175
176
177 public void setHeight(String height) {
178 this.height = height;
179 }
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194 @BeanTagAttribute
195 public String getWidth() {
196 return width;
197 }
198
199
200
201
202
203
204 public void setWidth(String width) {
205 this.width = width;
206 }
207
208
209
210
211
212
213
214
215
216
217 @BeanTagAttribute
218 public String getCaptionHeaderText() {
219 return captionHeaderText;
220 }
221
222
223
224
225
226
227 public void setCaptionHeaderText(String captionHeaderText) {
228 this.captionHeaderText = captionHeaderText;
229 }
230
231
232
233
234
235
236 @BeanTagAttribute
237 public Header getCaptionHeader() {
238 return captionHeader;
239 }
240
241
242
243
244
245
246 public void setCaptionHeader(Header captionHeader) {
247 this.captionHeader = captionHeader;
248 }
249
250
251
252
253
254
255
256
257
258
259
260 @BeanTagAttribute
261 public String getCutlineText() {
262 return cutlineText;
263 }
264
265
266
267
268
269
270 public void setCutlineText(String cutlineText) {
271 this.cutlineText = cutlineText;
272 }
273
274
275
276
277
278
279
280
281
282
283 @BeanTagAttribute
284 public Message getCutlineMessage() {
285 return cutlineMessage;
286 }
287
288
289
290
291
292
293 public void setCutlineMessage(Message cutlineMessage) {
294 this.cutlineMessage = cutlineMessage;
295 }
296
297
298
299
300
301
302 @BeanTagAttribute
303 public boolean isCaptionHeaderPlacementAboveImage() {
304 return captionHeaderPlacementAboveImage;
305 }
306
307
308
309
310
311
312 public void setCaptionHeaderPlacementAboveImage(boolean captionHeaderPlacementAboveImage) {
313 this.captionHeaderPlacementAboveImage = captionHeaderPlacementAboveImage;
314 }
315
316
317
318
319 @Override
320 public void completeValidation(ValidationTrace tracer){
321 tracer.addBean(this);
322
323
324 if(getSource()==null){
325 if(!Validator.checkExpressions(this, "source")){
326 String currentValues [] = {"source ="+getSource()};
327 tracer.createError("Source must be set",currentValues);
328 }
329 }
330
331
332 if(getAltText().compareTo("")==0){
333 if(Validator.checkExpressions(this, "altText")){
334 String currentValues [] = {"altText ="+getAltText()};
335 tracer.createWarning("Alt text should be set, violates accessibility standards if not set",currentValues);
336 }
337 }
338
339 super.completeValidation(tracer.getCopy());
340 }
341 }