summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui/declarative
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-10-01 21:05:29 +0300
committerTeemu Suo-Anttila <teemusa@vaadin.com>2015-10-19 13:23:42 +0300
commit32894becb285c53a92227462101968ae5b85e694 (patch)
tree24a07df9e9386e50285d71a5f9d3e1d6a0d9b633 /server/src/com/vaadin/ui/declarative
parentaf30540ddac9798eec5e326b1e72c56dacd7dd21 (diff)
downloadvaadin-framework-32894becb285c53a92227462101968ae5b85e694.tar.gz
vaadin-framework-32894becb285c53a92227462101968ae5b85e694.zip
Do not use getters/setters when mapping designer fields (#17388)
Change-Id: Id64193a109667286127038eb1c9dfd47697247be
Diffstat (limited to 'server/src/com/vaadin/ui/declarative')
-rw-r--r--server/src/com/vaadin/ui/declarative/FieldBinder.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/server/src/com/vaadin/ui/declarative/FieldBinder.java b/server/src/com/vaadin/ui/declarative/FieldBinder.java
index 577e9f5515..3766458175 100644
--- a/server/src/com/vaadin/ui/declarative/FieldBinder.java
+++ b/server/src/com/vaadin/ui/declarative/FieldBinder.java
@@ -18,7 +18,6 @@ package com.vaadin.ui.declarative;
import java.beans.IntrospectionException;
import java.io.Serializable;
import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -28,7 +27,6 @@ import java.util.Map;
import java.util.logging.Logger;
import com.vaadin.ui.Component;
-import com.vaadin.util.ReflectTools;
/**
* Binder utility that binds member fields of a design class instance to given
@@ -84,7 +82,7 @@ public class FieldBinder implements Serializable {
List<String> unboundFields = new ArrayList<String>();
for (Field f : fieldMap.values()) {
try {
- Object value = ReflectTools.getJavaFieldValue(bindTarget, f);
+ Object value = getFieldValue(bindTarget, f);
if (value == null) {
unboundFields.add(f.getName());
}
@@ -92,8 +90,6 @@ public class FieldBinder implements Serializable {
throw new FieldBindingException("Could not get field value", e);
} catch (IllegalAccessException e) {
throw new FieldBindingException("Could not get field value", e);
- } catch (InvocationTargetException e) {
- throw new FieldBindingException("Could not get field value", e);
}
}
if (unboundFields.size() > 0) {
@@ -192,15 +188,14 @@ public class FieldBinder implements Serializable {
return false;
}
// validate that the field is not set
- Object fieldValue = ReflectTools.getJavaFieldValue(bindTarget,
- field);
+ Object fieldValue = getFieldValue(bindTarget, field);
if (fieldValue != null) {
getLogger().fine(
"The field \"" + fieldName
+ "\" was already mapped. Ignoring.");
} else {
// set the field value
- ReflectTools.setJavaFieldValue(bindTarget, field, instance);
+ field.set(bindTarget, instance);
}
return true;
} catch (IllegalAccessException e) {
@@ -209,12 +204,18 @@ public class FieldBinder implements Serializable {
} catch (IllegalArgumentException e) {
throw new FieldBindingException("Field binding failed for "
+ identifier, e);
- } catch (InvocationTargetException e) {
- throw new FieldBindingException("Field binding failed for "
- + identifier, e);
}
}
+ private Object getFieldValue(Object object, Field field)
+ throws IllegalArgumentException, IllegalAccessException {
+ if (!field.isAccessible()) {
+ field.setAccessible(true);
+ }
+
+ return field.get(object);
+ }
+
/**
* Converts the given identifier to a valid field name by stripping away
* illegal character and setting the first letter of the name to lower case.