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>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy