From 64306d21e55686f75e98b8337f1346ec241446a9 Mon Sep 17 00:00:00 2001 From: Yuriy Artamonov Date: Tue, 29 Oct 2013 13:44:37 +0000 Subject: [PATCH] ControllerDependencyInjector problem with inject data sources from window parameters #PL-2797 --- .../cuba/gui/ControllerDependencyInjector.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/gui/src/com/haulmont/cuba/gui/ControllerDependencyInjector.java b/modules/gui/src/com/haulmont/cuba/gui/ControllerDependencyInjector.java index be92e9862a..69893dbd8f 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/ControllerDependencyInjector.java +++ b/modules/gui/src/com/haulmont/cuba/gui/ControllerDependencyInjector.java @@ -126,14 +126,17 @@ public class ControllerDependencyInjector { Object instance = getInjectedInstance(type, name, annotationClass); if (required && instance == null) - log.warn("Unable to find an instance of type " + type + " named " + name); + log.warn("CDI - Unable to find an instance of type " + type + " named " + name); else assignValue(element, instance); } private Object getInjectedInstance(Class type, String name, Class annotationClass) { + if (annotationClass == WindowParam.class) { + //Injecting a parameter + return params.get(name); - if (Component.class.isAssignableFrom(type)) { + } else if (Component.class.isAssignableFrom(type)) { // Injecting a UI component return frame.getComponent(name); @@ -161,10 +164,6 @@ public class ControllerDependencyInjector { // Injecting an ExportDisplay return AppConfig.createExportDisplay(frame); - } else if (annotationClass == WindowParam.class) { - //Injecting a parameter - return params.get(name); - } else { Object instance; // Try to find a Spring bean @@ -193,7 +192,7 @@ public class ControllerDependencyInjector { try { ((Field) element).set(frame, value); } catch (IllegalAccessException e) { - throw new RuntimeException(e); + throw new RuntimeException("CDI - Unable to assign value to field " + ((Field) element).getName(), e); } } else { Object[] params = new Object[1]; @@ -202,7 +201,7 @@ public class ControllerDependencyInjector { try { ((Method) element).invoke(frame, params); } catch (IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException(e); + throw new RuntimeException("CDI - Unable to assign value through setter " + ((Field) element).getName(),e); } } }