Including interface functions in cfc from cfml files on lucee or railo

I am trying to add an interface to cfc that includes some functions in the cfml file, however it gives an error message with the message "component [...] does not implement the interface function [..]" the function that it complains about is implemented in the included file cfml, I tested this in both railo 4 and lucee 5 and got the same error in both, but working in coldfusion 11 does anyone know if there is a workaround or fix for this in lucee or railo?

The following is an example code that reproduces the error.

int.cfc

interface { public numeric function func() output="false"; } 

comp.cfc

 component implements="int" { include "inc.cfm"; } 

inc.cfm

 <cfscript> public numeric function func() output="false"{ return 2; } </cfscript> 

index.cfm

 <cfscript> cfc = createObject("component", "comp"); writedump(cfc.func()); </cfscript> 
+5
source share
1 answer

One possible workaround I found is to replace the original cfc, which includes the cfml file with empty cfc, which implements the interface, but also extends the original cfc, renamed to another, by replacing the original cfc, you can keep the same type as well as adding an interface. Thus, the updated parts of the question example will look like this:

comp to extend.cfc

 component implements="int" { include "inc.cfm"; } 

comp.cfc

 component extends="comp-to-extend" implements="int" {} 
0
source

Source: https://habr.com/ru/post/1269229/


All Articles