That's interesting. I expected functions to have their own separate
buffer, just like custom tags. However, they still don't share a
buffer, because as you point out, they're all using different
PageContext objects, even though they happen to have the same content.
What I'm guessing happens is that when a CFC or method is started,
it's given a new PageContext (like a tag), but it's output buffer is
initialized to be the entire page's contents. Then, when the method
is ended, if the OUTPUT attribute is not false, the method's output
buffer replaces the current page's buffer.
The reason I suspect this is from how the OUTPUT attribute works. If
it's missing or set to true, the output of the method appears as
normal (the copy happend into and out of the method). If it's set to
false, the output of the method is not shown (the copy happened into
the method, but not out of it). However, if you do a CFABORT inside a
method, then the method's output, along with the rest of the page, is
displayed.
Again, that's all supposition. Maybe one of the MM guys can chime in
on the matter?
cheers,
barneyb
On Fri, 25 Feb 2005 10:32:08 -0000, Adam Cameron <[EMAIL PROTECTED]> wrote:
>
>
> Cheers Barney, that's interesting stuff.
>
> I pretty much see what's going on, although to me it more suggests that a
> <cfflush> should not be allowed INSIDE the custom tag file (it's not), but
> should be fine (and do what it's told) in the code on the calling page that
> happens to be within the custom tags, which should be a reference to flush
> whatever's in the buffer for that page context. But, anyway, yeah: it's
> predictable that CF was designed to do it the way it does.
>
> I've just run a similar test with a CFC function (which allows <cfflush>).
> It seems that despite each of the calling code, CFC-pseudo-constructor and
> function code all have different page contexts (my test of this is to do
> this: <cfdump var="#getPageContext().toString()#">; revealing different
> pointers for each), they all work with the SAME output buffer.
>
> Sorry to drag on... just trying to understand wha's going on and why.
>
> Just if you're interested, here's that code:
>
> <!--- caller.cfm --->
> <cfset request.buffer = structNew()>
> top of caller.cfm<br />
> <cfset request.buffer["1. Before createObject"] =
> getPageContext().getOut().getString()>
>
> <cfset o = createObject("component", "c")>
> after object creation<br />
> <cfset o.f()>
> after f()<br />
> <cfset request.buffer["4. after f()"] =
> getPageContext().getOut().getString()>
>
> before dump<br />
> <cfoutput>
> <table border="1">
> <cfloop collection="#request.buffer#" item="entry">
>
> <tr><td>#entry#</td><td>#htmlEditFormat(request.buffer[entry])#</td></tr>
> </cfloop>
> </table>
>
> </cfoutput>
> after dump<br />
> <cfoutput>#getPageContext().toString()#</cfoutput><br />
>
> <!--- c.cfc --->
> <cfcomponent>
> top of cfc<br />
> <cfset request.buffer["2. CFC"] =
> getPageContext().getOut().getString()>
> <cfoutput>#getPageContext().toString()#</cfoutput><br />
> <cffunction name="f">
> top of function<br />
> <cfset request.buffer["3. f()"] =
> getPageContext().getOut().getString()>
> <cfoutput>#getPageContext().toString()#</cfoutput><br />
> </cffunction>
> </cfcomponent>
>
>
> --
> Adam
>
--
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/
Got Gmail? I have 50 invites.
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]