Whatever message this page gives is out now! Go check it out!

Method chaining for CFC methods

Last update:
May 18, 2026
You can chain your CFC methods as follows:
emp=new employee(); 
emp.setFirstName("Tom").setLastName("Nash").setAge("30");
Chaining works only
  • If the attribute accessors is set to true
  • Until a method is found
  • If there are no errors or
  • If the setter functions for the properties are defined

Example

The chain in the example works only until lastName. This is because setter for age is set to false:
<cfcomponent accessors="TRUE"> 
<cfproperty name="firstname" type="string" setter="true"/> 
<cfproperty name="lastname" type="string" setter="true"/> 
<cfproperty name="age" type="numeric" setter="false"/> 
<cffunction name="init"> 
<cfreturn this> 
</cffunction> 
</cfcomponent>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page