Blog Archives - 2 Record(s)

Year: '2012' - Month: '7'

writing a model in cfscript

ColdBox, ColdFusion

So I've been wanting to rewrite stored procedures from markup to cfscript. I've done it so I'm posting an example for other newbies out there in the world to see.

public query function testFunction(var1,var2)


sp = new storedproc();



sp.addParam(cfsqltype="cf_sql_integer", type="in",value=arguments.var1);



result = sp.execute();

return result.GetProcResultSets(1).rs1;


That's it. I'm not sure what is the benefit. It seems that they could have made a shorter way of doing this. Maybe that's another post.


Migration to Coldbox 3.5 from 3.0: Using wirebox instead of the deprecated beanFactory

ColdBox, ColdFusion

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)




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


In my wirebox:


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.