2 possible solutions come to mind. The first is to not use a constructor-arg just use a property and have a setProductControler method in the controller. I think you will have better luck of the object being constructed at the right time that way.
The other path might be to just use modelglue.getBean("productControler") in your init to ask the beanfactory for the object.
Maybe somebody else will have a better idea of what the problem is, but HTH.
simeon
On 7/14/06, Doug Boude <[EMAIL PROTECTED]> wrote:
This is my first attempt to do any "manual" dependency injection using bean definitions within coldspring.xml, and I just can't get it to work.
The scenario:
Using MGU, latest code. I have two controllers - ProductController and WizardController, both residing in the "controllers" directory off of the app root. I want to inject, as a constructor argument, ProductController into WizardController.
coldspring.xml snippet
<bean id="productcontroller" class="controller.productcontroller" />
<bean id="wizcontroller" class="controller.wizardcontroller ">
<constructor-arg name="PController">
<ref bean="productcontroller" />
</constructor-arg>
</bean>
Init method of WizardController:
<CFFUNCTION name="init" returntype="controller.wizardcontroller" output="false" access="public">
<cfargument name="PController" type="controller.productcontroller " required="true" hint="Dependency product controller"/>
<cfset variables.prodcontroller = arguments.PController/>
<CFRETURN this />
</CFFUNCTION>
The Symptoms:
I receive the error whenever the wizardcontroller is instantiated:
The argument PCONTROLLER passed to function init() is not of type controller.productcontroller.
On an interesting side note, if i change the type argument to "Any", i get no error, but the object that gets injected into the PController variable is ModelGlue.unity.framework.ModelGlue
How's THAT for strange!
Can anybody see what I'm doing wrong?
