UPDATE: It seems that railo does not have this problem at all.
UPDATE: I vote to close this issue, as I feel that people are focusing more on the whole, “someone has a better idea sharing big components” part of this question (which I should never have inserted), then the real problem is using cfincludes with cfcomponent.
Note. This is just a simplified example of what I'm trying to do to convey an idea.
The problem I am facing is that I want to use cfinclude inside cfcomponent so that I can group similar methods into separate files for more manageability. The problem I am facing is when I try to extend another component that also uses cfinclude to control this method, as shown below. Note that ComponentA extends ComponentB:
ComponentA
==========
<cfcomponent output="false" extends="componentb">
<cfinclude template="componenta/methods.cfm">
</cfcomponent>
componenta/methods.cfm
======================
<cffunction name="a"><cfreturn "componenta-a"></cffunction>
<cffunction name="b"><cfreturn "componenta-b"></cffunction>
<cffunction name="c"><cfreturn "componenta-c"></cffunction>
<cffunction name="d"><cfreturn super.a()></cffunction>
ComponentB
==========
<cfcomponent output="false">
<cfinclude template="componentb/methods.cfm">
</cfcomponent>
componentb/methods.cfm
======================
<cffunction name="a"><cfreturn "componentb-a"></cffunction>
<cffunction name="b"><cfreturn "componentb-b"></cffunction>
<cffunction name="c"><cfreturn "componentb-c"></cffunction>
The problem is that when I try to initialize ComponentA, I get the error: "Routines cannot be declared more than once. Procedure a was declared twice in different templates."
The whole reason for this is that when you use cfinclude, it is computed in RUN TIME instead of COMPILE TIME.
, cfinclude, , - , ?