Reputation: 35359
Is there a way to access functions through inheritance without setting function access to public?
For example: I have Foo.cfc and it extends Bar.cfc. If I want to call a Bar.cfc function from Foo.cfc, I have to set the function access to public.
If I set the function access to private, then it's only accessible from Foo.cfc. Is there no "intermediate" access level that is not quite public but not strictly private? i.e. it allows access through inheritance only...
Upvotes: 1
Views: 2276
Reputation: 9759
You need to set the access property in cffunction to package. That will allow it to be accessed by any component that extends the component.
Upvotes: 1
Reputation: 32915
If I set the function access to private, then it's only accessible from Foo.cfc
NOT TRUE! private
access level in ColdFusion is same as protected
in Java, so you can still call that private method of Bar from Foo
Upvotes: 5
Reputation: 28873
Are you using the keyword super
? Because private methods should be available to sub components like Foo.cfc.
Foo.cfc
<cfcomponent extends="Bar">
.....
<cffunction name="fooMethod" access="public" ...>
<cfreturn super.nameOfAMethodInBarCFC() />
</cffunction>
</cfcomponent>
Upvotes: 6