Passing Coldbox RC2 settings to Wirebox

Hi
Trying to get started with wirebox. Converting from lightwire.

In lightwire i can inject structs whos values are settings in
coldbox's cfc. How can i do this in wirebox using dsl i guess.

this works
map("obj1")
      .to("components.Obj1")
      .initArg(name="arg1",dsl="coldbox.setting:myDsn");

this doesnt.
map("obj2")
      .to("components.Obj2")
      .initArg(name="arg1",dsl={key1="coldbox.setting:myVal1",key2="coldbox.setting:myVal2"});

Is this doable some way?

Thanks

ColdFusion doesn't support this type of code, the dsl={} needs to be done
outside of the function.

map("obj2").to("components.Obj2").initArg(name="arg1",dsl={key1="coldbox.set
ting:myVal1",key2="coldbox.setting:myVal2"});

So it becomes
dslProperties =
{key1="coldbox.setting:myVal1",key2="coldbox.setting:myVal2"};
map("obj2").to("components.Obj2").initArg(name="arg1",dsl=dspProperties);

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

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of Ade
Sent: Saturday, 26 February 2011 10:47 AM
To: ColdBox Platform
Subject: [coldbox:8340] Passing Coldbox RC2 settings to Wirebox

Hi
Trying to get started with wirebox. Converting from lightwire.

In lightwire i can inject structs whos values are settings in coldbox's

cfc. How

Yes you can. Inside of your binder you have access to the properties you initialized the Injector with (or coldbox settings) via several methods (see the docs I updated them today)

  • getProperty(name,default)
  • getProperties()
  • propertyExists()
  • setProperty()

ColdBox wires the Injector automatically with your configuraiton settings structure and you can use the above methods to get any one of them even complex ones.

so you can do this:
map(“obj1”)
.to(“components.Obj1”)
.initArg(name=“arg1”,value=getProperty(“myDSN”));

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Thanks for the response.
I tried your suggestions.

This version
map("obj1")
                        .to("components.Obj1")
                        .initArg(name="arg1",dsl="coldbox.setting:myDsn");

Does work i.e. it does resolve coldbox.settings.myDsn to the coldbox
setting value.

The second more complex case i found the following
This worked

myprops =
{websiteId=getProperty("websiteId"),sitesDsn=getProperty("sitesDsn")};
    map("ade")
      .to("components.Ade")
      .initArg(name="st",value=myProps);

this doesnt

    map("ade")
      .to("components.Ade")
      .initArg(name="st",value=
{websiteId=getProperty("websiteId"),sitesDsn=getProperty("sitesDsn")});

I get the error message
"
The property requested websiteId was not found , so whats the
difference?

Properties defined are
"

And then its blank for what properties there are.

Strangely enough this does work...

map("obj1")
                        .to("components.Obj1")
                        .initArg(name="arg1",value=getProperty("sitesDsn"));

Scott: i couldnt get your example to work.

Still i have enough to progress so many thanks