Our Forums are now closed. Please go to our Google Mailing List for help. This site will remain open for historical purposes.
ColdBox Framework Forums Home | Profile | Search | Login | RSS

 pdf Print PDF   Previous Page  Page: 1   Next Page

Thread: DSN property won't appear in instance
Created on: 03/11/10 07:57 AM Replies: 2
richard
Trying not to be a rookie

Joined: 03/09/09
Posts: 17
DSN property won't appear in instance
03/11/10 7:57 AM

Hi all,

pretty new to dependancy injection, but am now trying to use Coldbox's autowire functionality.

My problem is specifically relating to adding a DSN property into one of my service CFCs.

I've added these details to the top of my cfc

<cfcomponent displayname="CatalogueService" output="false" cache="true" cachTimeout="0">

   

   <!--- Dependencies --->

   <cfproperty name="CatalogueGateway"      type="model"                     scope="instance" />

   <cfproperty name="DSN"               type="coldbox:datasource:dsn"         scope="instance" />   

   <cfproperty name="SessionStorage"      type="coldbox:plugin:sessionstorage"   scope="instance" />   



   <cfscript>

      instance = structnew();

   </cfscript>



   <cffunction name="init" returntype="CatalogueService">

    <cfargument name="DSN" type="string" inject="#instance.dsn.getName()#" hint="Datasource" />

    <cfscript>

    variables.DSN = arguments.DSN;

    return this;

    </cfscript>

   </cffunction>


I've kept the init very similar to what I've used to use to prevent needing to change any of the code.

I was aware that coldbox 3 has standardised the name for wiring to "inject". However, I'm still on coldbox 2.6 (I think).

So to keep inline I added this line to the coldbox.cml.cfm file and <yoursettings> section

<Setting name="beanFactory_dslMarker"       value="inject"/>


Unfortunately I'm receiving this error:

=================
Application Execution Exception
Error Type: Application : [N/A]
Error Messages: The DSN parameter to the init function is required but was not passed in.
=================

and can't figure out why?? Is anyone able to show me the error of my way?
Thanks,

Richard
Link | Top | Bottom
lmajano
Veteran Master

Joined: 01/29/05
Posts: 1209
RE: DSN property won't appear in instance
03/11/10 1:14 PM

You are doing first of all twice the work, by adding a cfproperty which does mixin injections and then you have a constructor argument for injection.

Remove the constructor argument and just rely on the cfproperty injections.
Luis Majano
Link | Top | Bottom
richard
Trying not to be a rookie

Joined: 03/09/09
Posts: 17
RE: DSN property won't appear in instance
03/13/10 4:52 AM

Cheers Luis, that's made life easier.
Link | Top | Bottom

Galleon Forums V1.7.008 was created by Raymond Camden