Changeset 5233 for trunk/src/com/itmill/toolkit/data/util/BeanItem.java
- Timestamp:
- 08/21/08 10:18:44 (5 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/itmill/toolkit/data/util/BeanItem.java
r4543 r5233 9 9 import java.beans.PropertyDescriptor; 10 10 import java.lang.reflect.Method; 11 import java.util.Arrays; 11 12 import java.util.Collection; 12 13 import java.util.Iterator; … … 63 64 final String name = pd[i].getName(); 64 65 65 if ((getMethod != null) && (setMethod != null)) {66 if ((getMethod != null)) { 66 67 final Property p = new MethodProperty(type, bean, 67 68 getMethod, setMethod); … … 110 111 final Method setMethod = pd[i].getWriteMethod(); 111 112 final Class type = pd[i].getPropertyType(); 112 113 final Property p = new MethodProperty(type, bean, 114 getMethod, setMethod); 115 addItemProperty(name, p); 113 if ((getMethod != null)) { 114 final Property p = new MethodProperty(type, bean, 115 getMethod, setMethod); 116 addItemProperty(name, p); 117 } 116 118 } 117 119 } … … 142 144 */ 143 145 public BeanItem(Object bean, String[] propertyIds) { 144 this.bean = bean; 145 146 // Try to introspect, if it fails, we just have an empty Item 147 try { 148 // Create bean information 149 final BeanInfo info = Introspector.getBeanInfo(bean.getClass()); 150 final PropertyDescriptor[] pd = info.getPropertyDescriptors(); 151 152 // Add all the bean properties as MethodProperties to this Item 153 for (int j = 0; j < propertyIds.length; j++) { 154 final Object id = propertyIds[j]; 155 for (int i = 0; i < pd.length; i++) { 156 final String name = pd[i].getName(); 157 if (name.equals(id)) { 158 final Method getMethod = pd[i].getReadMethod(); 159 final Method setMethod = pd[i].getWriteMethod(); 160 final Class type = pd[i].getPropertyType(); 161 162 final Property p = new MethodProperty(type, bean, 163 getMethod, setMethod); 164 addItemProperty(name, p); 165 } 166 } 167 } 168 169 } catch (final java.beans.IntrospectionException ignored) { 170 } 146 this(bean, Arrays.asList(propertyIds)); 171 147 } 172 148
