Skip to content

Instantly share code, notes, and snippets.

@displague
Last active August 29, 2015 14:20
Show Gist options
  • Save displague/2f8e352fe4e851c02924 to your computer and use it in GitHub Desktop.
Save displague/2f8e352fe4e851c02924 to your computer and use it in GitHub Desktop.
<!--- Child.cfc --->
<cfcomponent extends="Parent">
<!--- No init method here. Inherits from Parent.cfc --->
</cfcomponent>
<!--- Grandparent.cfc --->
<cfcomponent>
<cfset variables.name = "">
<cffunction name="init">
<cfreturn this/>
</cffunction>
<cffunction name="getName">
<cfreturn variables.name>
</cffunction>
</cfcomponent>
<!--- Parent.cfc --->
<cfcomponent extends="Grandparent">
<cffunction name="init">
<cfargument name="name" required="true" type="string">
<cfset variables.name = arguments.name>
<cfreturn super.init()/>
</cffunction>
</cfcomponent>
Then, call the init function on Child passing in a name:
<!---
Calling init on Child should pass "name" to Parent.cfc
In CF11 Update 5 this throws an exception.
In CF11 Update 4 (and CF9) this executes without error.
--->
<cfset child = createObject("component", "Child").init(name = "Fred Flinstone")>
<cfoutput>#child.getName()#</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment