populatemodel using populateFromStruct?

Can anyone give me a simple example of populating a model using a struct?

I’m readying this and can’t figure it out.
http://wiki.coldbox.org/wiki/WireBox.cfm#populateFromStruct

in my handler I’m trying to:

LOCAL.documentBean = populateModel(“documentBean”).populateFromStruct(memento=LOCAL.mystruct);

I’m getting “The method populateFromStruct was not found in component”

either my documentBean isn’t extending the correct object or I’m missing something I was supposed to inject into the handler? I can populate the model from a form with no issues.

Thanks

Jonathan

You’re trying to use populateMode and populateFromStruct. You need to pick one. If your code is in a handler, you’re picking up the populateModel from the framework supertype which assumes you want to use the request collection as the struct to populate from.

To use your own struct, get the object populator from WireBox:
populator = injector.getObjectPopulator();

and call the populateFromStruct() method like you’re doing.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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

Got it. Thanks.