Highlighted

When will we be able to use cfmodule from inside of cfscript?

New Here ,
Nov 24, 2015

Copy link to clipboard

Copied

Is something like this planned as an update? When?

Currently we have to write really ugly code (script and tag code mixed) to get some legacy module files loaded into our components. I'm not talking about few files here, we have been using CF since version 5 and refactoring everything isn't an option.

Only workaround seems to create the ModuleTag java object in the coldfusion.tagext.lang package and call out the module that way. This is really hacky though since cfusion.jar can have class updates. Or perhaps there are some better solutions?

Views

896

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

When will we be able to use cfmodule from inside of cfscript?

New Here ,
Nov 24, 2015

Copy link to clipboard

Copied

Is something like this planned as an update? When?

Currently we have to write really ugly code (script and tag code mixed) to get some legacy module files loaded into our components. I'm not talking about few files here, we have been using CF since version 5 and refactoring everything isn't an option.

Only workaround seems to create the ModuleTag java object in the coldfusion.tagext.lang package and call out the module that way. This is really hacky though since cfusion.jar can have class updates. Or perhaps there are some better solutions?

Views

897

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 24, 2015 0
LEGEND ,
Nov 24, 2015

Copy link to clipboard

Copied

According to a blog by Adam Cameron from 2014, you _can_ use CFMODULE in CFSCRIPT - it's just module(arg,arg), not cfmodule(arg,arg).

HTH,

^_^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 24, 2015 0
New Here ,
Nov 24, 2015

Copy link to clipboard

Copied

That might be the case with Railo server which we don't use.

Both cfmodule & module methods give undefined variable error.

We are running CF10

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 24, 2015 0
Most Valuable Participant ,
Nov 27, 2015

Copy link to clipboard

Copied

That's because the cfmodule script equivalent of <cfmodule> wasn't added until CF11.

-Carl V.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 27, 2015 0
New Here ,
Nov 25, 2015

Copy link to clipboard

Copied

<!---   

Variables = new module(template="/cfm/filepath/file.cfm", {arg1="a", arg2="b"}, Variables)

--->

<cfcomponent>

<cffunction name="init" output="True" access="Public" returnType="Any">

    <cfargument name="template" type="String" required="True">

    <cfargument name="moduleArguments" default="#StructNew()#">

    <cfargument name="superVariables" default="#StructNew()#">

    <cfmodule template="#Arguments.template#" attributecollection="#Arguments.moduleArguments#" />

    <cfset StructDelete(Variables, "init")>

    <cfset StructDelete(Variables, "this")>

    <cfreturn StructAppend(Arguments.superVariables, Variables)>

</cffunction>

</cfcomponent>

// Variables = new module("/path/file.cfm", {arg1="", arg2=""}, Variables);

This is the wrapper I've been working on so far.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 25, 2015 0