• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Nov 24, 2015 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

1.1K

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
community guidelines
LEGEND ,
Nov 24, 2015 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,

^_^

Votes

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
community guidelines
New Here ,
Nov 24, 2015 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

Votes

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
community guidelines
Guide ,
Nov 27, 2015 Nov 27, 2015

Copy link to clipboard

Copied

LATEST

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

-Carl V.

Votes

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
community guidelines
New Here ,
Nov 25, 2015 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.

Votes

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
community guidelines
Resources
Documentation