1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.labs.kitchensink;
17
18 import org.apache.commons.lang.StringUtils;
19
20 import java.beans.PropertyEditorSupport;
21 import java.io.Serializable;
22
23
24
25
26 public class UITestPropertyEditor extends PropertyEditorSupport implements Serializable {
27 private static final long serialVersionUID = -4113846709722954737L;
28
29
30
31
32 @Override
33 public String getAsText() {
34 Object obj = this.getValue();
35
36 if (obj == null) {
37 return null;
38 }
39
40 String displayValue = obj.toString();
41 if (displayValue.length() > 3) {
42 displayValue = StringUtils.substring(displayValue, 0, 3) + "-" + StringUtils.substring(displayValue, 3);
43 }
44
45 return displayValue;
46 }
47
48
49
50
51 @Override
52 public void setAsText(String text) {
53 String value = text;
54 if (StringUtils.contains(value, "-")) {
55 value = StringUtils.replaceOnce(value, "-", "");
56 }
57
58 this.setValue(value);
59 }
60
61 }