From 3ef30789d6ac773eed7346dcaa670426fa6f662c Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 10 Jan 2017 12:22:34 +0200 Subject: Refactor AbstractDateField. (#8146) First round for #8132. --- .../com/vaadin/ui/declarative/DesignAttributeHandler.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java') diff --git a/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java b/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java index 4c7a2da9a8..42ffe303ef 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java +++ b/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java @@ -21,6 +21,7 @@ import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.io.Serializable; import java.lang.reflect.Method; +import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -36,6 +37,7 @@ import org.jsoup.nodes.Attributes; import org.jsoup.nodes.Element; import org.jsoup.nodes.Node; +import com.googlecode.gentyref.GenericTypeReflector; import com.vaadin.data.Converter; import com.vaadin.data.ValueContext; import com.vaadin.shared.ui.AlignmentInfo; @@ -115,8 +117,9 @@ public class DesignAttributeHandler implements Serializable { success = false; } else { // we have a value from design attributes, let's use that - Object param = getFormatter().parse(value, - setter.getParameterTypes()[0]); + Type[] types = GenericTypeReflector + .getExactParameterTypes(setter, target.getClass()); + Object param = getFormatter().parse(value, (Class) types[0]); setter.invoke(target, param); success = true; } @@ -208,7 +211,9 @@ public class DesignAttributeHandler implements Serializable { Object value = getter.invoke(component); Object defaultValue = getter.invoke(defaultInstance); writeAttribute(attribute, attr, value, defaultValue, - (Class) getter.getReturnType(), context); + (Class) GenericTypeReflector.getExactReturnType(getter, + component.getClass()), + context); } catch (Exception e) { getLogger().log(Level.SEVERE, "Failed to invoke getter for attribute " + attribute, -- cgit v1.2.3