Shaun Mccran

My digital playground

06
O
C
T
2008

Calling Component methods in one function call

Sometimes I want to return a data object from a specific method within a cfc, but in one hit. Why code an object creator, then a call to a method in that object, when you can do it in one go.

view plain print about
1<cfset variables.myFusebox = createObject("component","myFusebox").init(variables.FUSEBOX_APPLICATION_KEY,variables.attributes,variables) />

In the code above I am creating a variable "variables.myFuseBox". This becomes the return data from the object "myFuseBox" which is invoked with the createObject command. I am then passing the ".init" command to reference the "init" method in the CFC.

Lastly I'm passing in a list of arguments to the init method in the standard way.

TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Back to top