Is there a replacement for populateFromQuery? I’d like to populate an instantiated bean from a query.

Sorry, for the dumb question but I can’t find an example in the docs.

LOCAL.myQuery=myService.myFunction(somevalue); //I have my model injected in my handler and I’m using it to create a query of data

LOCAL.myBean=populateModel(‘myBean’); //I grab from some data from the form and put in a bean

Now, I have some data in LOCAL.myQuery that I want to populate in the bean. Sorry, but I do this besides using individual setters?

I see this http://wiki.coldbox.org/wiki/WireBox.cfm#populateFromQuery

No examples and I’m at a loss.



You just need to inject the wirebox object populator into your cfc and then use that function. Something like:

property name=“pop” inject=“wirebox:populator”;


that’s it!

sorry - forgot to add the query! should have said:


Thanks for the help. I’m off and running.

Now that I've used the populateFromQuery, I'm trying to learn
populateFromXML. In this case my XML is pretty simple.


I'm looking at the wiki but due to lack of examples, I struggle.


My sample code:

LOCAL.bounce=emailService.getBounceList(); //API call that gets me XML

LOCAL.myArray=arrayNew(1); //create an array to populate

rc.bounce.filecontent,root='recipients'); //populate the array right??

Thanks for any advice.


It looks like that method has some requirements for how the XMl should be structured. I would just look at the code to see how it works. Here is the meat of it:

// iterate and build struct of data
childElements = arguments.xml[arguments.root].XMLChildren;
for(x=1; x lte arrayLen(childElements); x=x+1){
arguments.memento[ childElements[x].XMLName ] = trim(childElements[x].XMLText);

return populateFromStruct(argumentCollection=arguments);



ColdBox Platform Evangelist
Ortus Solutions, Corp

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

Corrected code. Maybe I can’t use an array? So I try a struct.