11package ng .appserver ;
22
33import java .util .Map ;
4- import java .util .Objects ;
54
65import ng .appserver .elements .NGStructuralElement ;
76
@@ -14,7 +13,7 @@ public class NGComponentReference extends NGDynamicElement implements NGStructur
1413 /**
1514 * Holds a reference to the fully qualified class name of the component we're going to render
1615 */
17- private final NGComponentDefinition _componentDefinition ;
16+ private NGComponentDefinition _componentDefinition ;
1817
1918 /**
2019 * The bindings being passed from the parent component to the component being rendered.
@@ -35,13 +34,21 @@ public class NGComponentReference extends NGDynamicElement implements NGStructur
3534 */
3635 public NGComponentReference ( final String componentName , final Map <String , NGAssociation > associations , final NGElement contentTemplate ) {
3736 super ( null , null , null );
38- Objects .requireNonNull ( componentName );
39- Objects .requireNonNull ( associations );
40- _componentDefinition = NGApplication .application ().elementManager ().componentDefinition ( componentName );
4137 _associations = associations ;
4238 _contentTemplate = contentTemplate ;
4339 }
4440
41+ /**
42+ * @return A new component reference for the given component definition
43+ *
44+ * CHECKME: A little sucky, but required for passing in the component definition
45+ */
46+ public static NGComponentReference of ( final NGComponentDefinition componentDefinition , final Map <String , NGAssociation > associations , final NGElement contentTemplate ) {
47+ NGComponentReference reference = new NGComponentReference ( null , associations , contentTemplate );
48+ reference ._componentDefinition = componentDefinition ;
49+ return reference ;
50+ }
51+
4552 private void beforeComponent ( final NGContext context ) {
4653 // Let's take hold of component that's being rendered, before we hand control to the new component
4754 final NGComponent previousComponent = context .component ();
0 commit comments