What's the ColdFusion 9 script syntax for cfsetting?
Asked Answered
O

5

18

I'm trying to convert an Application.cfc to script. The original had this:

<cfcomponent displayname="Application" output="false">
     <cfset this.name               = "testing">
     <cfset this.applicationTimeout = createTimeSpan(0,1,0,0)>
     <cfset this.sessionManagement  = true>
     <cfset this.sessionTimeout     = createTimeSpan(0,0,30,0)>

     <cfsetting requesttimeout="20">
     ...

I can't figure out how to convert the cfsetting tag to script. The following attempts don't work:

setting requesttimeout="20"; // throws a "function keyword is missing in FUNCTION declaration." error.
setting( requesttimeout="20" ); // throws a "Variable SETTING is undefined." error.

It looks like Railo may be supporting it (link), but I can't find an equivalent for the cfsetting tag in ColdFusion's documents

Orbit answered 8/11, 2011 at 18:50 Comment(1)
It doesn't help you in CF9, but CF10 added native cfsetting to script.Jaclyn
J
24

There isn't one. Normally I'd suggest filing an ER for this, but there already is. What I'd recommend is putting into a CFM file and using include to bring it in.

Jaclyn answered 8/11, 2011 at 18:52 Comment(2)
Does voting for the error report help, or is it already accepted and going to be fixed for next version?Tope
The bug has been closed as "fixed". CF10 appears to have a setting tag-equivalent.Krebs
U
8

Give this a try

<cfscript>
createObject( "java", "coldfusion.tagext.lang.SettingTag" ).setRequestTimeout( javaCast( "double", 20 ) );
</cfscript>

or this

<cfscript>
createObject( "java", "coldfusion.runtime.RequestMonitor" ).overrideRequestTimeout( javaCast( "long", 20 ) );
</cfscript>

where 20 is your cfsetting requesttimeout value

Unceremonious answered 20/11, 2011 at 13:17 Comment(0)
A
7

In CF11 (and I think CF10), per the docs you can do:

setting enablecfoutputonly="true" requesttimeout="180" showdebugoutput="no";
Amphoteric answered 23/9, 2015 at 15:25 Comment(1)
The question is about CF9, but since this is a top result in Google regardless of version I thought it would be useful to include here and to include the actual code sample.Amphoteric
C
4

These cfml scripts:

<cfsetting enablecfoutputonly="true" />
<cfsetting requesttimeout="60" />
<cfsetting showdebugoutput="false" />

should work in cfscript as these:

createObject( "java", "coldfusion.tagext.lang.SettingTag" ).setEnablecfoutputonly(true);
createObject( "java", "coldfusion.tagext.lang.SettingTag" ).setRequestTimeout(javaCast( "double", 60 ));
createObject( "java", "coldfusion.tagext.lang.SettingTag" ).setShowdebugoutput(false);
Calandra answered 28/8, 2012 at 15:20 Comment(2)
As this is not documented, I would not recommend using this in production code.Jaclyn
Poor documentation is no excuse for not using features built in to the software. The only difference is you are just responsible for ensuring they are still present in future editions. There has been plenty of documented features that have broken in newer versions anyway. So, long story short, make sure you use a testing framework and trust your tests more than incomplete/inaccurate documentation. </rant>Unceremonious
C
0
setting.requesttimeout="3000";

This should work

Clover answered 25/6, 2021 at 17:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.