[Wirebox 3.7] Advanced object creation

Not quite sure of the “right” way to handle this one.

I have a bean, a transient, that there will be several of. It has several setters on it, but the first setter returns a “key”. For example:

local.oX = createObject(‘component’, ‘x’)
local.sKey = local.oX.addFeature(args…);

The next calls required the “key”.
local.oX.setSomething(local.sKey, ‘a’);

local.oX.setSomethingElse(local.sKey, ‘b’);

For a given object, I could have n… calls to these types of functions, one “addFeature” per feature. Now, in my Wirebox file, I’m doing this all in straight code. Honestly, I’m not even sure how to “name” the objects (Wirebox alias) doing this style.

But short of creating a massive inline struct (which is horribly impossible in CF9, unlike Railo), and passing said struct as an initArg() to each bean to handle the n… calls I might have to set it up, I don’t know a better way to do it. I’m concerned that I’m a) creating a bunch of bean configs when the bean might not get called and b) that when I do call it, the binder doesn’t actually execute at runtime, as wirebox.getInstance() won’t know how to run a function to create them. Can anyone offer some insight as to the right way to do this with my poblem at hand?

I’m sure some factory method would be the right way to go, but just haven’t had to do this before. Again, I’m trying to avoid passing a large init struct of arrays of structs, etc.

Okay, I figured out half of my problem. I can do the inline-code style of creation and then use map(‘bob’).toValue(local.oConfig). Didn’t realize that was an option.

However, clearly I’m still in need of the solution portion that enables me to create these config aliases without actually creation the objects in the Wirebox binder file directly.

Can you try to explain again what you’re doing or perhaps show some code? My head’s feeling a little cloudy right now and for the life of me I don’t understand what you’re after.

These “setters”-- are the part of the initialization of the bean when its created? What values are you setting? Are they static-- the same every time?

Can you show some code to explain what you meant when you said, " in my Wirebox file, I’m doing this all in straight code."

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

— Can you show some code to explain what you meant when you said, " in my Wirebox file, I’m doing this all in straight code."