Saturday 2 August 2014

Are the docs for <cfexit> wrong, or am I misunderstanding?

G'day:
Just before I update the ColdFusion docs and file a bug with Railo, can someone please santiy check this.

The docs for <cfexit> say this:

Attribute Req/Opt Default Description
method Optional exitTag
  • exitTag: aborts processing of currently executing tag.
  • exitTemplate: exits page of currently executing tag.
  • loop: re-executes body of currently executing tag.

However the default seems to be exitTemplate.

This code demonstrates:

<!--- testExitBug.cfm --->
<cfparam name="URL.exitmethod" default="">
<cfimport taglib="." prefix="tag">
<tag:exitBug exitmethod="#URL.exitmethod#">
    inner text
</tag:exitBug>

// exitBug.cfm
param attributes.exitmethod="";

writeOutput("thistag.executionMode: [#thistag.executionMode#]<br>");

if (thistag.executionMode == "start"){
    writeOutput("We don't need to do anything in the start tag, so exiting<br>");

    if (len(attributes.exitMethod)){
        writeOutput("exitMethod: [#attributes.exitmethod#]<br>");
        exit attributes.exitmethod;
    }

    writeOutput("exitMethod: [none specified]<br>");
    exit;
}

writeOutput("processing the end tag<br>");
writeOutput("thisTag.generatedContent: [#thisTag.generatedContent#]<br>");

So I can run testExitBug.cfm and specify the exitMethod to use on the URL, and it will filter through to the tag and be used when exiting.

For example, this URL: http://localhost:8511/scribble/shared/scratch/blogExamples/cfml/customtags/railo/testExitBug.cfm, yields this result:

thistag.executionMode: [start]
We don't need to do anything in the start tag, so exiting
exitMethod: [none specified]
inner text thistag.executionMode: [end]
processing the end tag
thisTag.generatedContent: [ inner text ]


This looks like the exitTemplate behaviour:
http://localhost:8511/scribble/shared/scratch/blogExamples/cfml/customtags/railo/testExitBug.cfm?exitmethod=EXITTEMPLATE

thistag.executionMode: [start]
We don't need to do anything in the start tag, so exiting
exitMethod: [EXITTEMPLATE]
inner text thistag.executionMode: [end]
processing the end tag
thisTag.generatedContent: [ inner text ]


Not the exitTag behaviour:
http://localhost:8511/scribble/shared/scratch/blogExamples/cfml/customtags/railo/testExitBug.cfm?exitmethod=EXITTAG

thistag.executionMode: [start]
We don't need to do anything in the start tag, so exiting
exitMethod: [EXITTAG]


Am I missing something?

The bug with Railo is that it follows the docs, not the behaviour:
http://localhost:8888/scribble/shared/scratch/blogExamples/cfml/customtags/railo/testExitBug.cfm

thistag.executionMode: [start]
We don't need to do anything in the start tag, so exiting
exitMethod: [none specified]


http://localhost:8888/scribble/shared/scratch/blogExamples/cfml/customtags/railo/testExitBug.cfm?exitmethod=EXITTAG

thistag.executionMode: [start]
We don't need to do anything in the start tag, so exiting
exitMethod: [EXITTAG]


http://localhost:8888/scribble/shared/scratch/blogExamples/cfml/customtags/railo/testExitBug.cfm?exitmethod=EXITTEMPLATE

thistag.executionMode: [start]
We don't need to do anything in the start tag, so exiting
exitMethod: [EXITTEMPLATE]
inner text thistag.executionMode: [end]
processing the end tag
thisTag.generatedContent: [ inner text ]


I'll hold off updating the docs / raising a bug with Railo until someone can cast a second set of eyes over this and confirm I'm correct here.

BTW: CF9, 10 and 11 all have the same behaviour here. And I'm testing on Railo 4.2.1.003.

Cheers.

--
Adam