[ColdBox 4.3.0] Modeling a collection of objects

Long-time CF guy but ColdBox newb here, aware of it forever, haven’t really used it.

I’m thinking about a model to represent cumulative stats on a collection of objects, each of whose data is a json file in the file system. That strikes me as two model objects, one for an individual object and one for the collection.

Outside of ColdBox, I’d create an instance of the collection object, which would get a list of all the applicable files, and for each one, call new Item(filePath), ask it for its individual info, and accumulate the collection stats.

Is there a ColdBox-style equivalent to those new Item(filePath) calls? AFAIK, there’s no way to represent creating multiple instances of a transient (non-singleton) model object.

Is there some concept or syntax I’m unaware of, or should I just go with native new Item() calls?


Welcome aboard Dave!!

The concept you are talking about is an object model concern and not a ColdBox concern. Thus, you would use WireBox to create the objects for you to provide you with consistency, dependency injection and state. So just leverage WireBox to create the objects for you.

wirebox.getInstance( “path or alias” );

Luis Majano
Ortus Solutions, Corp

Support Our Open Source Projects: www.patreon.com/ortussolutions
Linked In: http://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/lmajano

Thanks for jumping in Louis.

I thought Wire*B*ox was for dependency injection, and I didn't see a way to
"inject" multiple new transients. I hadn't thought about asking the DI
provider for them, sounds reasonable.