1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.web.bind;
17
18 import org.springframework.beans.BeanWrapperImpl;
19 import org.springframework.beans.BeansException;
20 import org.springframework.beans.InvalidPropertyException;
21 import org.springframework.beans.NullValueInNestedPathException;
22 import org.springframework.beans.PropertyValue;
23
24
25
26
27
28
29
30 public class UifBeanWrapper extends BeanWrapperImpl {
31
32 private BeanWrapperImpl rootBeanWrapper;
33
34 public UifBeanWrapper(Object object) {
35 super(object);
36 }
37
38 public UifBeanWrapper(Object object, String nestedPath, UifBeanWrapper superBw) {
39 super(object, nestedPath, superBw);
40
41 setRootBeanWrapper(superBw.getRootBeanWrapper());
42 }
43
44
45
46
47
48
49 @Override
50 public Object getPropertyValue(String propertyName) throws BeansException {
51 return getPropertyValue(propertyName, false);
52 }
53
54
55
56
57
58
59
60
61 protected Object getPropertyValue(String propertyName, boolean autoGrowNestedPaths) {
62 setAutoGrowNestedPaths(autoGrowNestedPaths);
63
64 Object value = null;
65 try {
66 value = super.getPropertyValue(propertyName);
67 } catch (NullValueInNestedPathException e) {
68
69 } catch (InvalidPropertyException e1) {
70 if (!(e1.getRootCause() instanceof NullValueInNestedPathException)) {
71 throw e1;
72 }
73 }
74
75 return value;
76 }
77
78
79
80
81
82
83 @Override
84 public void setPropertyValue(PropertyValue pv) throws BeansException {
85 setAutoGrowNestedPaths(true);
86
87 super.setPropertyValue(pv);
88 }
89
90
91
92
93
94
95 @Override
96 public void setPropertyValue(String propertyName, Object value) throws BeansException {
97 setAutoGrowNestedPaths(true);
98
99 super.setPropertyValue(propertyName, value);
100 }
101
102
103
104
105
106
107 @Override
108 protected BeanWrapperImpl newNestedBeanWrapper(Object object, String nestedPath) {
109 return new UifBeanWrapper(object, nestedPath, this);
110 }
111
112
113
114
115
116
117
118
119
120 @Override
121 protected BeanWrapperImpl getBeanWrapperForPropertyPath(String propertyPath) {
122 if (this.rootBeanWrapper != null) {
123 setAutoGrowNestedPaths(this.rootBeanWrapper.isAutoGrowNestedPaths());
124 }
125
126 return super.getBeanWrapperForPropertyPath(propertyPath);
127 }
128
129
130
131
132
133
134 public BeanWrapperImpl getRootBeanWrapper() {
135 if (rootBeanWrapper == null) {
136 return this;
137 }
138
139 return rootBeanWrapper;
140 }
141
142
143
144
145 public void setRootBeanWrapper(BeanWrapperImpl rootBeanWrapper) {
146 this.rootBeanWrapper = rootBeanWrapper;
147 }
148 }