> This works...
>
> obj= createObject("component","cfc.MyClass");
> obj.init(application.id);
> obj.executeMethod();
>
>
> But this does not?
>
> obj= createObject("component","cfc.MyClass").init(application.id);
> obj.execute();
>
> on cfc...
>
> <cfcomponent>
>        <cffunction name="init" access="public">
>                <cfargument name="id" required="true">
>                <cfscript>
>                        this.id = arguments.id;
>                </cfscript>
>        </cffunction>
>        <cffunction name="execute" access="public">
>                <cfreturn true/>
>        </cffunction>
> </cfcomponent>

You need to return the object instance within your init method to use
object chaining. You should also specify the returntype in your init
method signature.

<cffunction name="init" access="public" returntype="MyClass">
     ...
     <cfreturn this>
</cffunction>

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authori

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336346
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to