Hi,
I am not sure if this post belongs in the MG or the Coldspring forum, but
here goes:
I use Coldspring with my MG application and I have a component like this:
<cfcomponent displayname="CMSGateway"
extends="Application.model.Gateways.BaseGateway" output="false">
<cffunction name="init">
<cfreturn THIS>
</cffunction>
[....]
This component is defined in Coldspring.xml: <bean id="CMSGateway"
class="Application.model.Gateways.CMSGateway" />
I want to make a variable accessible to all functions in this component and
so I put it in init():
<cffunction name="init">
<cfset Variables.searchCriteria={}>
<cfset Variables.searchCriteria.domainname="mydomainname">
<cfset Variables.searchCriteria.id="">
<cfset Variables.searchCriteria.language="">
<cfreturn THIS>
</cffunction>
This works and all my functions have now access to the
Variables.searchCriteria variable. It gets initialised once and I don't
have to put this code in all functions that need it.
Since "mydomainname" is defined in the Applicationconfiguration bean
(ModelGlue.Bean.CommonBeans.SimpleConfig in Coldspring.xml), I change line
<cfset Variables.searchCriteria.domainname="mydomainname">
to
<cfset
Variables.searchCriteria.domainname=getApplicationConfiguration().getConfigSetting("domainname")>
and add
<cfproperty name="ApplicationConfiguration">
in the pseudo-constructor area just above the init function. Using
Dependancy Injection I should be able to call getApplicationConfiguration()
to get a reference to ApplicationConfiguration. So I have now
<cfproperty name="ApplicationConfiguration">
<cffunction name="init">
<cfset Variables.searchCriteria={}>
<cfset
Variables.searchCriteria.domainname=getApplicationConfiguration().getConfigSetting("domainname")>
<cfset Variables.searchCriteria.id="">
<cfset Variables.searchCriteria.language="">
<cfreturn THIS>
</cffunction>
But when requesting a page I get an error
"Bean creation exceptio""n during init() of
Application.model.Gateways.CMSGateway
Variable GETAPPLICATIONCONFIGURATION is undefined.: "
Obviously, I am not able to use Dependency Injection this way.
I tried to move the block where I define Variables.searchCriteria _and_ the
associated cfproperty to the init handler of the parentclass
(baseGateway.cfc) but that doesn't work either
Is there something missing in my understanding of Dependency Injection or
does it not work this way?
Marc
CF 9.01
CS 1.2
MG 'Gesture' 3.2 RC1
--
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog
You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en