So I want to migrate from coldbox 3.0 to 3.5 but I the beanFactory plugin was deprecated. I'm already using wirebox to do injection of models in my apps but I never got around to changing the beans. So here is an example I am trying.

Here is what I was doing before in my handler:

LOCAL.myBean = getPlugin("beanFactory").populateBean("model.myBean");

rc.formXML = CreateObject("component", "app.bin.utilityLib").formToXML(LOCAL.myBean.toStruct());

This is WAY TO UGLY for a fancy OO framework like Coldbox.

 

Here is what I am trying to do now. I created a new bean because I'm doing nothing but cfscript these days.

My bean:

component hint="I'm trying to be an example bean that sets default values."

{

property name="firstName" type="string" default="first"; //set a default value incase I'm not submitting a form just yet.

function getFirstName() { return THIS.firstName; } //a getter

function setFirstName(firstName) { THIS.firstName=arguments.firstname;} //a setter

}

My handler:

function groovyBeans(event,rc)

{

rc.test1=populateModel("testBean");

rc.test2=testBean.getFirstName();

event.setView("groovy"); //this view does nothing other than dump the RC.

}

In my wirebox:

map("testBean").to("model.testBean").asSingleton();

Now only problem is my default isn't getting set. It's telling me that THIS.firstName isn't defined. I can see that my bean is being created because I see in rc.test1 the bean object is there.