Copy link to clipboard
Copied
When I try to get a page content by getPageContext().getCFOutput().getString() in onRequestEnd event, I get an empty string.
When I try to get a page content at the end of cfm script by the same code, I get what I expect: not empty content.
Application.cfc:
...
<cffunction name="onRequestEnd" output="false" returntype="void" >
<cfargument type="String" name="targetPage" required=true />
<cfdump var="getPageContext().getCFOutput().getString() in onRequestEnd: [#getPageContext().getCFOutput().getString()#]" output="C:\debug\debug_test_log.html" format="html" />
</cffunction>
...
test.cfm:
blah blah blah
<cfdump var="getPageContext().getCFOutput().getString() in test.cfm: [#getPageContext().getCFOutput().getString()#]" output="C:\debug\debug_test_log.html" format="html" />
The debug output (dumped into file) is following:
getPageContext().getCFOutput().getString() in test.cfm: [blah blah blah ]
getPageContext().getCFOutput().getString() in onRequestEnd: []
Any idea why it is empty in onRequestEnd event?
I remember it was working as expected in previous CF server versions and I was able to modify or cache an output before sending to a client.
Copy link to clipboard
Copied
The cfdump tag in test.cfm might be messing things up for you.
Comment it out and see whether that helps.
Copy link to clipboard
Copied
The cfdump tag in test.cfm might be messing things up for you.
Comment it out and see whether that helps.
By @BKBK
What I mean is, try something like:
<cfoutput>blah blah blah</cfoutput>
<!---
<cfdump etc.>
--->
Copy link to clipboard
Copied
BKBK, thank you for your response!
cfdump tag in test.cfm doesn't affect, I checked.
What I found is output="false" parameter in onRequestEnd function. It does affect.
If I change it to output="true" or omit it entirely, it starts working fine, I get the output content.
In case of output="true" it dumps the content generated only inside onRequestEnd function and ignores the output from test.cfm file.
Copy link to clipboard
Copied
Sorry, typo... Should be:
In case of output="false" it dumps the content generated only inside onRequestEnd function and ignores the output from test.cfm file.
Copy link to clipboard
Copied
And if bkbk's helpful idea doesn't pan out, another sanity check would be to create a new folder, with that test page (doing absolutely nothing but that blah blah, before or after), and an Application.cfc doing also nothing but that onrequestend method (and not extending any other cfc). Does the function still fail to produce any result?
If that works, then clearly something else in your app.cfc (or any you extend/inherit from) or something in your test cfm is impacting your first efforts.
If that's the case (or if it fails to work also in this other test), what if you wrap the blah blah in a cfoutput? Not that you should have to, but does it make any difference? Just tossing out diagnostics to try, not solutions for now.
Copy link to clipboard
Copied
It was output="false" parameter in OnRequestEnd
Once I change it to output="true" or omit it entirely, it resolves the issue.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
In case of output="false" in onRequestEnd it dumps the content generated only inside onRequestEnd function and ignores the output from test.cfm file.
Copy link to clipboard
Copied
And thank you for your response, Charlie!
Copy link to clipboard
Copied
Deleted
Copy link to clipboard
Copied
Sorry, @Charlie Arehart and @sergey_croitor. My forum page didn't refresh. So I missed your your recent posts. Please, ignore what I said.
Copy link to clipboard
Copied
@BKBK, in my case the highlighted parameter was the reason of issue. Do you have it defined in your onRequestEnd?
Copy link to clipboard
Copied
FWIW, I had noticed that, but since you were doing a cfdump to a file, I presumed it may not impact. But are you saying even with that false, and a cfoutput around your blah blah, the it still didn't dump anything (from within that onrequestend)?
Copy link to clipboard
Copied
@Charlie Arehart, with output="false" it dumps only what is inside OnRequestEnd. It ignores the content from test.cfm. In browser I see the opposite: the content from test.cfm only, without the content from onRequestEnd.
A bit confusing 🙂 Anyway output="true" resolves my issue.