> Thanks and apologies... I should have just said
"CFCONTENT does not work when
> called from within any AJAX container," for example
CFDIV, CFWINDOW,
> CFLAYOUTAREA.
> [...]
> The result is exactly as tSpark described... I see the
HTML table
> in a standard browser window, it does not launch and
display in Excel. The same
> code works as expected (and as I've used it repeatedly
for at least 4 or 5
> years) if it is in a non-AJAX page.
Right. Well I think you might be misunderstanding how all
this works.
Firstly, here's a very small replicable case:
<!--- mimeTypeTestMain.cfm --->
<cfwindow initshow="true" source="./mimeTypeTestInner.cfm"
/>
<!--- mimeTypeTestInner.cfm --->
<cfcontent type="application/msexcel" reset="true">
<cfheader name="Content-Disposition"
value="filename=mimeTypeTestInner.xls">
<table border="1">
<tr><td>Foo</td></tr>
<tr><td>Bar</td></tr>
</table>
As you say, this just displays an HTML table in the window.
Now, first things first, the <cfcontent> tag is indeed
doing its job
exactly as intended. If you watch the underlying HTTP
requests/responses
taking place, you'll see the MIME type of
mimeTypeTestInner.cfm is indeed
being set to application/excel, and the content-disposition
is being set to
the correct file name.
However that sort of thing is only ever interpretted by the
browser as
starts receiving a new response from a request it itself has
made (you
know, typing in a URL in the address bar, or clicking on a
link or
sumbitting a form on the referring page, etc.
A <cfwindow> is *not* a "window" in the sense of a
browser window (or a
browser frame or iframe), it's just a <div> with some
styling applied to it
to make it look "window-y". Part of the <cfwindow> tags
functionality is
that behind the scenes, a Javascript XML object is making a
request back to
the server to get the content for the window as specified in
the "source"
attribute. Having received some data back, some client side
JS (which
<cfwindow> has previously sent down to the browser)
grabs it and pops it
into the innerHtml of the <div>. It doesn't pay any
attention to your
headers. It doesn't actually make any sense it pay any
attention to header
information like that, because the content of the request is
being
integrated into an existing doc, which already has a name and
a MIME type.
Make sense?
I've singled out <cfwindow> here because I happen to be
getting myself up
to speed with CF8 at present, and <cfwindow> was one of
those tags I have
never used in production code: so it's kind of "on my radar"
at present.
The other AJAX-esque tags will work the same way, for the
same reasons
though.
--
Adam