Dependency Injection not working for me

56 views
Skip to first unread message

Jason

unread,
Nov 11, 2010, 11:34:49 AM11/11/10
to ColdBox Platform
Hello,

I am a newbie to ColdBox so please forgive me if I am overlooking
something very basic. However, I am having a hard time getting the
dependencies to inject into both my handlers and my model.

Here is one example that I am trying to work out. I need to get
access to event.BuildLink() inside my model, so I did the following:

1) I added <cfproperty name="modelRC" type="coldbox:requestService"
scope="instance"> at the top of the CFC
2) In the function I added:

<cfset var event = instance.modelRC.getContext() />

#event.buildLink('mylinkstuff')#

However I am getting an error that says that ModelRC is undefined. In
my Coldbox.cfc my IOC configuration is set as follows so I can use
ColdSpring.

//IOC Integration
ioc = {
framework = "coldspring",
reload = true,
objectCaching = false,
definitionFile = "config/coldspring.xml.cfm"
};

Any help would be great as getting this to work has been the biggest
problem for me. I am thinking I have to be missing a setting
someplace but I could not figure out where.

Thanks!

Jason

Sana

unread,
Nov 11, 2010, 11:43:26 AM11/11/10
to ColdBox Platform
Hi Jason,

In latest coldbox version the syntax is like this (type -> inject)
<cfproperty name="modelRC" inject="coldbox:requestService"
scope="instance">

Which version of coldbox you are using ...?

Thanks

Jason

unread,
Nov 11, 2010, 1:07:15 PM11/11/10
to ColdBox Platform
Thank you for the reply. I did change that but it still did not want
to work for some reason.

So I have the following.

<cfproperty name="modelRC" inject="coldbox:requestService"
scope="instance">

And I am dumping instance in one of the functions so I can see if
modelRC is created but it is not in the dump.

I am running ColdBox 3.0.0 (M6.2-318-GENESIS-14:14)

Jason

br...@bradwood.com

unread,
Nov 11, 2010, 1:37:53 PM11/11/10
to col...@googlegroups.com
Shouldn't that be <cfproperty name="modelRC" inject="coldbox:model:requestService"
scope="instance"> ?

Also, you can turn on debug logging for coldbox.system to see information on what is happening.

~Brad
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org

Jason

unread,
Nov 11, 2010, 3:44:47 PM11/11/10
to ColdBox Platform
Thank you both. Enabling the logging was a huge help - took me a bit
to figure out how to get it to log, but once I did it was great and I
fixed the issue.
> To post to this group, send email toco...@googlegroups.com
> To unsubscribe from this group, send email tocoldbox-...@googlegroups.com

adk

unread,
Nov 11, 2010, 3:55:51 PM11/11/10
to ColdBox Platform
ummm... how DO you turn that on?

Andrew Scott

unread,
Nov 11, 2010, 5:46:22 PM11/11/10
to col...@googlegroups.com
Something like this in your ColdBox.cfc config file

logBox = {
// Define Appenders
appenders = {
coldboxTracer = {

class="coldbox.system.logging.appenders.AsyncRollingFileAppender",
properties={filePath='../logs',
fileName='NameofLogFile', autoExpand=true, fileMaxSize=2000,
fileMaxArchives=10}
}
},
root = { levelMin=logBoxConfig.logLevels.FATAL,
levelMax=logBoxConfig.logLevels.DEBUG, appenders="*"}
};


Regards,
Andrew Scott
http://www.andyscott.id.au/

> To post to this group, send email to col...@googlegroups.com To


> unsubscribe from this group, send email to coldbox-

> unsub...@googlegroups.com


> For more options, visit this group at http://groups-
> beta.google.com/group/coldbox

Brad Wood

unread,
Nov 11, 2010, 9:11:07 PM11/11/10
to col...@googlegroups.com
Thanks for throwing an example out there Andrew. Yes, basically LogBox
(which comes baked into ColdBox) let's you set up appenders (or places where
your log messages are stored) and configure them to only listen to messages
logged from certain places in your application or messages logged with
certain severity levels. ColdBox's autowiring automatically logs a ton of
debug-level information, but by default, messages with a DEBUG severity are
ignored from anywhere within "coldbox.system"; possibly with a config like
so:

categories = { "coldbox.system" = { levelMax="INFO" }}

Changing it like so would enable debug messages to be logged from ColdBox's
core.

categories = { "coldbox.system" = { levelMax="DEBUG" }}

You can even configure LogBox to use different settings per environment.
It's VERY flexible. It's so action packed, it usually makes Luis giddy just
thinking about it. :)

~Brad

Luis Majano

unread,
Nov 11, 2010, 10:09:13 PM11/11/10
to col...@googlegroups.com
I got giddy just reading about it!!

Sent from my iPhone

> --
> You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
> To post to this group, send email to col...@googlegroups.com

> To unsubscribe from this group, send email to coldbox-u...@googlegroups.com

Reply all
Reply to author
Forward
0 new messages